Reputation: 7254
I'm writing service tests with database(without mocks).
I have a new requirement to perform common database "health" checks* after each test in our test suits.
The question is: where can I put this kind of tests/checks?
At first I thought about TearDown, but AFAIK it was supposed(designed) to perform cleanup not assertions. Would it be ok to put it there?
I'm not doing anything on teardown right now (and that is probably not going to change) - the database is cleaned on SetUp and each and every test is responsible for preparing the environment for itself.
*- the database design is inherited from another company and unfortunately its very poor - we've discovered inconsistencies in data and that's why we need to perform 'health checks' to identify places where they occur
Upvotes: 0
Views: 752
Reputation: 236318
From NUnit documentation:
[TearDown] attribute is used inside a TestFixture to provide a common set of functions that are performed after each test method is run.
There is nothing about cleanup or assertions. Just about time of invocation - after each test is run. So yes, it's completely OK to perform here health checks after test was run.
Upvotes: 2