开发者

Loading a different dataset per test method in DBUnit

开发者 https://www.devze.com 2023-01-22 04:59 出处:网络
I\'m trying to use DBUnit to tes开发者_高级运维t my DAO layer methods. Every method needs different set of seed data.

I'm trying to use DBUnit to tes开发者_高级运维t my DAO layer methods. Every method needs different set of seed data.

Example:

getEmployeeById(Long id) needs data from Employee table

updateOrder(CustomerId cId) needs data from Orders table

Is there an elegant way to load different seed data before running different methods instead of loading all the data at a time in a setUp method?

Thank you.


The current DbUnit implementation does not provide any support for such feature, I would suggest you to split in multiple test cases, one for each seeding data set. My usual approach is having one test case per business object; staying on your example ExmpoyeeTest will check on Employee table, OrderTest will check on OrderTable.

Next DbUnit major version will allow what you require through annotations.

About your comment: you asked for different seeding data set while your comment regards checking data set... I think you got confused ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消