May
29

I was in the middle of a TDD coaching session a couple of days ago when it hit me - people need a tool that will help them write one assert at a time!

So I started looking for one, and after about 2 exhausting minutes of trying to Google it, I gave up and wrote one myself.

Give it a try at http://www.rauchy.net/oapt.

0
September
2

I just found out that you can create compound constraints in NUnit (starting in v2.4). This means that you can logically group constraints.

For example, I am currently testing a custom IList<T> implementation, and in a specific test case, I want to make sure a specific entry exists instead of another. Before compound constraints, I would have written these 2 asserts:

Assert.That(this.subject, Has.Member(”rauchy”));
Assert.That(this.subject, Has.No.Member(”Omer”));

My problem with this code is that these two asserts represent a single fact - I want to make sure that rauchy makes it to the list, and not Omer. One might interpert them as two independent facts. With compound constraints, I can just write:

Assert.That(this.subject, Has.Member(”rauchy”) & Has.No.Member(”Omer”));

This way, you cannot think of this as two independent facts. Also, this helps follow the one-assert-per-test rule.

0