I would like to be able to simulate a failure of an arbitrary test in order to check that my TearDown logic works correctly. A unit test on a unit test, if you please.
But really, I have TearDown in some fixtures that produces attachments on failures. I must be able to show off this feature, but it is hard to produce a failure when you most need it.
So, I want to create a test parameter specifying the name of a test I wish to fail. Now, I can easily write an attribute implementing IWrapTestMethod
or IApplyToContext
, but then I need to apply it on every test method.
Is there a way to implement it without touching every test and/or fixture? By some kind of an assembly level attribute or assembly level setup method that would run before each and every test?
It is crucial that this logic would not prevent the TearDown
methods from running, so ITestAction
throwing an exception from BeforeTest
does not fit the bill.
Can this be done?