I discovered [Theory]
and [Datapoint]
attributes in NUnit. I am not very sure about how should I use these. I think they can be used for data-driven testing and this has got me interested. There aren't many resources available on the same. Can someone explain to me how to use them or point me to resources? Thanks.
The following xUnit attributes enable writing a suite of similar tests: [Theory] represents a suite of tests that execute the same code but have different input arguments. [InlineData] attribute specifies values for those inputs.
Summary. Test methods marked with the [Theory] attribute can have input parameters, and have values passed to them by using the [InlineData] attribute. In this way, a single test method can support many tests, and developers save significant time writing tests by using these attributes.
The Test attribute is one way of marking a method inside a TestFixture class as a test.
When a test is marked as data theory, the data fed into it from the data source is directly mapped to the parameters of the test method.
Have you looked at the online NUnit docs? There's an example here that shows you how you can use the [Theory] and [Datapoint] attributes:
http://www.nunit.org/index.php?p=theory&r=2.5.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With