Describing your tests
To facilitate working with test suites composed by several tests, NUnit offers different attributes to further describe your fixtures and their tests.
Here is a list of all the attributes supported in NUnit.
Category
The Category
attribute provides an additional dimension to group tests. The attribute can be applied to both a fixture or individual tests. The same test can belong to more than one category.
Most runners offer the possibility to specify which categories to include or exclude in a test run. Tests belonging to excluded categories will not be reported at all.
Optionally, you can create your own category attributes by inheriting from the built-in one. This is useful to avoid the risk of mispell of the category names.
To facilitate this scenario, the Category
attribute exposes a parameterless protected constructor that will use the attribute name as name of the category.
You can then proceed using the new attribute as usual
Here is the official documentation for the Category attribute.
Property
Similarly to the Category
attribute, the Property
one gives the developer to specify additional properties of the unit test. The attribute can be applied to both a fixture or individual tests.
Developers can also create their own attributes by inheriting the Property attribute and providing the value via the protected constructor while the property name will be inferred from the attribute class name.
You can then proceed using the new attribute as usual
Here is the official documentation for the Property attribute.
Description
The Description
attribute lets the developer apply a descriptive test to the test or the whole fixture.
Here is the official documentation for the Description attribute.
TestOf
The TestOf
attribute lets the developer specify the class that is being tested. The attribute can be applied to both a fixture or individual tests.
This attribute can be used by certain IDE to bind tests to tested components.
Here is the official documentation for the TestOf attribute.
Last updated