Geeks With Blogs
Lee Brandt's Blog You're only as smart as your last line of code

While traditional syntax for asserts is fairly easy to understand (once you get used to reading it), it doesn’t read as close to English as I’d like. So I have taken to using the Assert.That syntax for a lot of my assertions. This makes an assert like this:

   1: Assert.AreEqual(5, SUT.Items.count);

Read like this:

   1: Assert.That(SUT.Items.Count, Is.EqualTo(5));

To me, the second assert reads a lot more like plain English.

 

~Lee

Posted on Monday, October 13, 2008 11:01 AM TDD | Back to top


Comments on this post: NUnit Assert.That Syntax Makes Assertions Easier to Read

# re: NUnit Assert.That Syntax Makes Assertions Easier to Read
Requesting Gravatar...
would you please help me about UnitTest(C#) and details of it and assert 's methods
Left by karami on Oct 29, 2008 6:31 AM

# re: NUnit Assert.That Syntax Makes Assertions Easier to Read
Requesting Gravatar...
http://www.xprogramming.com/xpmag/acsUsingNUnit.htm This is a good referencefor getting started as well as Pragmatic Unit Testing In C# with NUnit book.

Hope this helps,
~Lee
Left by Lee Brandt on Oct 31, 2008 5:17 AM

Your comment:
 (will show your gravatar)


Copyright © Lee Brandt | Powered by: GeeksWithBlogs.net