If I make a test that should throw a fatal error, how can I handle that? For instance, how can I write this test to ensure a variable is deleted properly:
[Test]
public static void TestScope()
{
String str;
{
str = scope .();
}
str.ToUpper(); // str should be marked as deleted here
}
You can parameterize the
Test
attribute asTest(ShouldFail=true)
.The test process first runs all tests that shouldn't fail, then runs all tests that should. If any tests that should fail don't, the remaining should-fail tests are still run.
For instance, testing this class:
...will first successfully complete
TestScopeShouldNotFail
, then will unexpectedly completeTestScopeShouldFailButSucceeds
, then will expectedly fail inTestScopeShouldFail
. Thus, it will produce one failed test forTestScopeShouldFailButSucceeds
.