Legacy Documentation. View NUnit 3 Documentation

DatapointAttribute / DatapointsAttribute (NUnit 2.5) (Experimental)

The Datapoint and Datapoints attributes are used to provide data for Theories and are ignored for ordinary tests - including tests with parameters.

When a Theory is loaded, NUnit creates arguments for each of its parameters by using any fields of the same type as the parameter annotated with the DatapointAttribute. In addition, elements of arrays of the required type annotated with the DatapointsAttribute are also used.

Note: In the current release, these attributes are only recognized when used exactly as specified above. In particular, they may not be used on methods or properties and the DatapointsAttribute may only be placed on an array. These limitations will be removed in a later release.

Automatically Supplied Datapoints

It is normally not necessary to specify datapoints for boolean or enum arguments. Beginning with version 2.5.4, NUnit automatically supplies values of true and false for boolean arguments and will supply all defined values of any enumeration.

If for some reason you don't wish to use all possible values, you can override this behavior by supplying your own datapoints. If you supply any datapoints for an argument, automatic datapoint generation is suppressed.


For an example of use, see TheoryAttribute.

See also...