2014-02-11 66 views
0

我是jUnit的新手,有一个任务来编写具有一些复杂数据库组件的应用程序的jUnit测试用例。我可以为数据库组件编写测试用例,并且在本地maven构建创建时可以正常运行。但是在部署框中,我从jenkins maven命令创建构建时没有可用的数据库。请建议!如何为数据库组件编写jUnit测试用例?

回答

2

jUnit的扩展名为dbUnit,旨在创建测试运行之间的已知可重现状态。在CI框(以及本地)上与内存数据库(如HSQL或H2)一起使用应该很适合您。

干杯,

+0

为我工作! –

0

可以基于嘲弄和集成测试其真实DB运行单元测试中分离你的测试。仅在Jenkins中运行单元测试

0
I am working same kind of project. In our application we use test schema and a reusable class which loads the data from the XML(File is same as test class) and Cache the data and removes the data from the table, so that Unit test get intended data. 
We set different profile and these are set via JVM arguments. And these profile have the database details and any other admin stuff required. In case of Junit to run we use the unit test profile.