On tearing down my unit tests I want to check that the database has been returned to the status quo ante (subject to certain tolerances) before proceeding with the next test. I know I could always load a fresh copy of the original database, but in fact returning to the status quo ante is part of verifying that only those changes that I intend are actually occurring.
But it turns out that if you put a self.assertXXX
in tearDown()
, and if this fails, it is not reported as a failure at the end.
One thing I could do is to have a common procedure which every test_XXX
method would have to call as its last command, but I'm just wondering how the pros handle this sort of situation.
I'm also interested to know how this is viewed in the "philosophy" of unit-testing: a lack of data compliance post-test is not actually a coding failure... so how should it be handled?
Aucun commentaire:
Enregistrer un commentaire