Reputation: 55512
I was just reading through the Nunit 2.5 docs and came across the Theory attribute, and I'm having a little bit trouble understanding how this is different to a normal unit test and how it could be used.
What makes it different from a normal test?
What situations would you use this kind of test?
I just can't seem to get my head around it :(
Upvotes: 30
Views: 8473
Reputation: 346546
A Theory is similar to a parameterized test, with the additional ability to define assumptions under which it must pass, which are checked before actually performing the test and its assertions.
Basically, it could be used if you have a lot of data points and want to check a certain behaviour that should be guaranteed - but not always, only under certain preconditions.
Upvotes: 31
Reputation: 116442
a theory is an elegant alternative to parameterized test, see my question here at stackoverflow
Upvotes: 3