简体   繁体   中英

Db unit tests. Constraints disabling

I have a set of unit tests which test my DAO layer. I have following requirements: - For one subset of tests I need to disable constraints(foreign key, unique, not null). - For other subset I need to remain their (I check data integrity here).

So for several test I want to enable constraints, for other to disable.

Firstly I tried to use DbMantainer(part of Unitils), because it has disable constraint option. But after that I looked into sources and found that it can only remove(through alter table) constraints at the moment when I start migration process. After constraints were removed once(before I launch first test), I can't enable their later (integrity tests).

So my questions are: 1. Can you suggest me other tools (like DbMantainer or Unitils) which can disable constraints? 2. If no such tools exist what is in your opinion the best option to disable and enable constraints in db unit testing?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM