vineri, 4 decembrie 2009

NUnit - basic

[TestFixture] attribute - applied to a class (has to be public and to have a default ctor)
[Test] attribute
- applied to methods indicating that it is a test method
- method returns void and has no parameter.
Assert class defines a collection of methods used to check the post-conditions
.AreEquals(object, object) -- the first parameter is an expected value and the second parameter is the actual value
[ExpectedException] attribute - this is the way to indicate that the test code is expecting an exception of a certain type; if such an exception is not thrown during the execution – the test will fail.
[Ignore] attribute - temporarily ignore a test method
[SetUp] attribute
- applied to methods
- it has void return type, no parameters
- put a common set of test objects to all test methods
- has the common initialization code

Steps to test with NUnit:
- Start the NUnit Gui
- Select the File->Open menu item, navigate to the location of your dll
- Click the Run button
- See the “Errors and Failures” panel
- GUI watches for the changes made to the test assemblies and updates itself when the structure of the test tree has changed – e.g. new test is added

Niciun comentariu:

Trimiteți un comentariu