我是jUnit的新手,有一個任務來編寫具有一些複雜數據庫組件的應用程序的jUnit測試用例。我可以爲數據庫組件編寫測試用例,並且在本地maven構建創建時可以正常運行。但是在部署框中,我從jenkins maven命令創建構建時沒有可用的數據庫。請建議!如何爲數據庫組件編寫jUnit測試用例?
0
A
回答
2
jUnit的擴展名爲dbUnit,旨在創建測試運行之間的已知可重現狀態。在CI框(以及本地)上與內存數據庫(如HSQL或H2)一起使用應該很適合您。
乾杯,
1
通常的做法是在內存數據庫環境中爲CRUD功能編寫單元測試。不完全是真實的東西,但方式不那麼危險。看看
http://www.h2database.com/html/main.html
http://www.oracle.com/technetwork/articles/javase/javadb-10-5-142692.html
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.
相關問題
- 1. 如何編寫junit mokito測試用例
- 2. 如何編寫JUnit測試?
- 3. 編寫JUnit測試來測試一組
- 4. 如何爲下面的類編寫JUnit測試用例?
- 5. 編寫DAO的Junit測試用例
- 6. 爲JUNIT測試用例指定數據
- 7. 編寫JUnit測試
- 8. 編寫JUnit測試案例對Struts
- 9. 單元:如何使用jUnit和Mockito編寫測試用例
- 10. 如何使用JUnit編寫數據驅動的測試3
- 11. 如何爲參數化的jUnit測試用例編寫一個ant腳本?
- 12. 如何編寫一個junit測試用例添加方法?
- 13. 如何在Spring Mapper類中編寫junit測試用例
- 14. 如何編寫JUNIT測試用例進行嘲諷?
- 15. 如何編寫未知輸出的JUnit測試用例
- 16. 如何編寫JUnit測試用例來檢查值的範圍?
- 17. 如何編寫低於類的junit測試用例
- 18. Junit測試數據庫
- 19. 如何編寫android jUnit功能測試
- 20. 如何正確編寫JUnit測試?
- 21. 如何編寫junit測試腳本?
- 22. Junit測試用例在數據庫中插入數據
- 23. 如何編寫junit測試用例返回虛擬存儲庫會話
- 24. JUnit - 如何爲文件解析方法編寫測試?
- 25. 如何將使用Mockito編寫的jUnit測試用例轉換爲EasyMock
- 26. 編寫更好的JUnit參數化測試用例
- 27. JUnit測試用例 - 設置數據
- 28. 如何編寫JUnit測試案例在列表
- 29. 如何編寫JUnit測試案例的XPath
- 30. 如何爲創建新對象的void方法編寫junit測試用例
爲我工作! –