I've been using NUnit for a while now, and I have been deriving my test classes from AssertionHelper
. By doing that, my tests use a syntax like:
Expect(myValue, Is.EqualTo(3), "value wasn't equal to 3");
instead of:
Assert.That(myValue, Is.EqualTo(3), "value wasn't equal to 3");
Almost every example with NUnit that I see uses Assert.That()
syntax, but it seems that Expect()
makes more sense (at least to me) as I am expecting a certain behavior from my code.
Is there any downside to using AssertionHelper
with NUnit, or is it really come down to just a matter of taste/style?
Thanks in advance!
Both doing the same and both allows you specifying a custom constraint which implements IConstraint
interface. From my point of view Assert()
a little bit lightweight since does not obligate you inheriting all test fixtures from a special class.
The main issue with AssertionHelper
is that very few people use it, so new NUnit features and constraints tend not to get added to it. Because it is neglected and not widely used, the NUnit team is considering removing it or making it a separate package.
The team is looking for feedback from the community on whether or not to remove it, so feel free to comment on the issue.
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