Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What will we use Theory Attribute for?

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.

like image 889
Sandbox Avatar asked May 25 '10 01:05

Sandbox


People also ask

What is Theory in unit testing?

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.

What is Theory and inline data?

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.

Which attribute is used to mark the test class in the N unit?

The Test attribute is one way of marking a method inside a TestFixture class as a test.

What attribute marks a test method as being data driven?

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.


1 Answers

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

like image 171
Paddyslacker Avatar answered Oct 12 '22 22:10

Paddyslacker