2014-02-11 70 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.