Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a reason not to use AssertionHelper with NUnit?

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!

like image 429
David Hoerster Avatar asked Dec 14 '11 20:12

David Hoerster


2 Answers

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.

like image 167
sll Avatar answered Jan 01 '23 06:01

sll


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.

like image 41
Rob Prouse Avatar answered Jan 01 '23 05:01

Rob Prouse