Game Development Reference
In-Depth Information
[TestFixture]
A class containing the methods that make up the testing performed on a class is
marked with the [TestFixture] attribute. A common naming convention used is to
take the name of the class you want to test, and append Tests on to the end. For
example, if we are testing SimpleClass , it is common to name our test fixture
SimpleClassTests . These will be the names used in the provided examples.
The following code snippet shows how to use this attribute:
[TestFixture]
public class SimpleClassTests
{
}
Note
Classes marked with the [TestFixture] attribute must have a public default constructor or no
constructors at all. Without any constructors, a public default constructor will be created implicitly.
[Test]
A method in a test fixture marked with the [Test] attribute will be executed when
the test fixture is tested with NUnit.
The following code snippet shows how to use this attribute:
[TestFixture]
public class SimpleClassTests
{
[Test]
public void TestSomething()
{
}
}
Note
It is important that a [Test] method be marked public, return void, and not take in any parame-
ters.
[SetUp]
A method in a [TestFixture] marked with the [SetUp] attribute will be executed
immediately before each test is run.
 
Search Nedrilad ::




Custom Search