I am unit-testing a a .NET project using visual studio’s own framework where each test needs to close certain connections so that the next test may run correctly. However, when a test fails, this cleanup is not performed, and as a result all subsequent tests fail.
Is there a way I can execute a method everytime a test fails?
Try to put your cleanup logic into a method decorated by the
[TestCleanUp]attribute.See the MSDN for details.