开发者

Loading a different dataset per test method in DBUnit

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜