I'm testing datasource layer using dbunit, junit, liquibase, hsqldb. I'm using in memory-state of hsqldb. Each time I start test, I create db structure using liquibase via command line:
@BeforeClass
public static void setupDatabase() throws Exception
{
...
try{
Main.main( new String[]{
"--defaultsFile=db/properties/db.test.properties",
开发者_运维技巧 "--logLevel=debug",
"update"}
);
}catch(Exception e){
System.out.println( e );
}
System.out.println( "QQQQ" );
...
}
In the output I can see, that sql scripts are executed successfully:
Connected to SA@jdbc:hsqldb:mem:datasourcedb
...
Successfully released change log lock
Liquibase Update Successful
But for some reason I can not see the output from System.out.println
. I develop in IDEA. I see Process finished with exit code 0.
in debug window, but at the same time I see that
test has not been terminated. I suppose the first message is related to the "main" function.
Any Idea?
I'm going to hazard a wild guess, but if you're using liquibase.integration.commandline.Main.main(String[])
to run your Liquibase update scripts then you shouldn't be—that method exits with System.exit(0)
.
Instead, take a look at this forum post which describes how to run Liquibase updates programmatically, specifically for use in unit tests.
精彩评论