liquibase 创建数据库后不开始测试
我正在使用 dbunit、junit、liquibase、hsqldb 测试数据源层。 我正在 hsqldb 的内存状态中使用。 每次开始测试时,我都会通过命令行使用 liquibase 创建数据库结构:
@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" );
...
}
在输出中我可以看到,sql 脚本已成功执行:
Connected to SA@jdbc:hsqldb:mem:datasourcedb
...
Successfully released change log lock
Liquibase Update Successful
但由于某种原因,我看不到 System.out.println< 的输出/代码>。我是用IDEA开发的。我在调试窗口中看到
Process finish with exit code 0.
,但同时我看到 测试尚未终止。我想第一条消息与“main”功能有关。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我打算大胆猜测,但如果您使用 liquibase.integration.commandline.Main.main(String[]) 来运行 Liquibase 更新脚本,那么您不应该 —该方法以
System.exit(0)
退出。相反,请查看此论坛帖子,其中描述了如何以编程方式运行 Liquibase 更新,专门用于单元测试。
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 withSystem.exit(0)
.Instead, take a look at this forum post which describes how to run Liquibase updates programmatically, specifically for use in unit tests.