Game Development Reference
In-Depth Information
Notice that the above class has been marked with the [TestFixture] attribute. This
is required so that NUnit can identify the test fixtures to run by searching all classes
within the assembly that have this attribute type.
Running Tests
After the test fixture is created, it is time to begin testing. As mentioned previous-
ly, there are two interfaces for NUnit: console and GUI. This chapter will cover the
GUI version. For now, we will explicitly launch the NUnit application, but later on,
an alternative method is discussed that shows how to attach NUnit to the start
event in Visual Studio. There is also an open source project called TestDriven.NET
that offers enhanced .NET unit testing functionality, including integration sup-
port between Visual Studio and various unit testing frameworks like NUnit; defi-
nitely worth looking at.
Start by launching the NUnit GUI version, and you should be presented with a
dialog similar to the one shown in Figure 10.3.
Figure 10.3 Screenshot of main NUnit interface.
You will be prompted to save the NUnit project somewhere, and it is common to
place the .nunit file in the same directory as the project file for the assembly being
tested. After the project file is saved, you need to add the assemblies that contain
your test fixtures. You can do this by selecting Project>Add Assembly from the
main menu.
Figure 10.4 shows the NUnit interface after the example test fixture for this chap-
ter has been added to it.
Search Nedrilad ::




Custom Search