I created a unit test that passed NCrunch locally but then failed during a gated build on the TFS build server. It appears NCrunch runs TestCleanup code differently from how it is processed by MSTest when the test is decorated with the ExpectedException attribute.
This test class demonstrates the problem, where exceptions that occur during TestCleanup are ignored by unit tests decorated with the ExpectedException attribute:
Code:
[TestClass]
public class TheTestClass
{
[TestCleanup]
public void ExceptionsOccurringDuringCleanupAreIgnoredOnTestsMarkedWithExpectedExceptionAttribute()
{
Assert.Fail();
}
[ExpectedException(typeof(Exception))]
[TestMethod]
public void ThisTestPassesWithNCrunch()
{
throw new Exception();
}
[TestMethod]
public void ThisTestFailsWithNCrunch(){ }
}
Is this an NCrunch bug? If so, will it be corrected?