Legacy Documentation. View NUnit 3 Documentation

Parameterized Tests

NUnit 2.5 supports parameterized tests. Test methods may have parameters and various attributes are available to indicate what arguments should be supplied by NUnit.

Multiple sets of arguments cause the creation of multiple tests. All arguments are created at the point of loading the tests, so the individual test cases are available for display and selection in the Gui, if desired.

Some attributes allow you to specify arguments inline - directly on the attribute - while others use a separate method, property or field to hold the arguments. In addition, some attributes identify complete test cases, including all the necessary arguments, while others only provide data for a single argument. This gives rise to four groups of attributes, as shown in the following table.

Complete Test CasesData for One Argument
Inline TestCaseAttribute RandomAttribute
Separate TestCaseSourceAttribute ValueSourceAttribute

In addition, when data is specified for individual arguments, special attributes may be added to the test method itself in order to tell NUnit how to go about combining the arguments. Currently, the following attributes are provided: