Game Development Reference
In-Depth Information
This attribute causes the test or test fixture to be exempt from testing. This attribute
must accept a string parameter describing why the test or test fixture is ignored.
The following code snippet shows how to use this attribute:
[TestFixture]
public class SimpleClassTests
{
[Test]
[Ignore(“Broken functionality at the moment, so testing is pointless”)]
public void TestSomething()
{
}
}
[ExpectedException]
There may be situations where it is expected that an exception should be thrown,
and this attribute exists to avoid the need for an ugly try-catch block. When a test
is marked with the [ExpectedException] attribute and the expected exception that
is specified in this attribute is thrown, the test is still successful. The only way a
thrown exception will cause this test to fail is if the exception is not the same type
specified using this attribute. Also keep in mind that multiple [ExpectedException]
attributes can be specified if more than one expected exception should be ignored.
The following code snippet shows how to use this attribute:
[TestFixture]
public class SimpleClassTests
{
[Test]
[ExpectedException(typeof(InterfaceDesignerException))]
public void TestSomething()
{
}
}
Caution
You must be very specific when stating the expected exception since NUnit is not aware of excep-
tion inheritance. If the exception thrown is derived from InterfaceDesignerException , the test
would fail. The expected exception stated must be identical to the exception that will be thrown.
 
Search Nedrilad ::




Custom Search