Andrew Stopford's Weblog

poobah

Sponsors

News

Articles

Family

Old Blogs

NUnit 2.5 RTM

Charlie and the NUnit team have been working hard on NUnit 2.5 and over the last weekend the NUnit 2.5 RTM was released, a huge kudos to Charlie and the team on getting this out. NUnit 2.5 has loads of new goodies, parameterized tests (like MbUnit) and Theories (like JUnit and XUnit.net) caught my eye, seeing parameterized tests in NUnit really shows how much MbUnit has brought this concept into the .NET mainstream and it is exciting to see in NUnit. So lets take a look.

   1:  using NUnit.Framework;
   2:   
   3:  [TestFixture]
   4:  public class SummerTest
   5:  {
   6:      [Test, Sequential]
   7:      public void TestAddSequential([Values(2,4)] int expected, 
   8:          [Values(1,2)] int value1, 
   9:          [Values(1,2)] int value2)
  10:      {
  11:          Assert.AreEqual(expected, value1 + value2);
  12:      }
  13:   
  14:      [TestCase(2, 1, 1)]
  15:      [TestCase(3, 1, 2)]
  16:      public void TestAddCombin(int expected, int value1, int value2)
  17:      {
  18:          Assert.AreEqual(expected, value1 + value2);
  19:      }
  20:  }

In both cases we are seeking to add two numbers together and compare to a result. I have shown two slightly different ways of approaching the same test, the first test sets values on the sums and expected within the parameter, the second test shows how you can also split them out.

The only thing I recommend is using the TD.NET beta with NUnit 2.5 or your tests won't work correctly.

Posted: May 05 2009, 11:00 PM by andrewstopford | with 3 comment(s)
Filed under: ,

Comments

Dew Drop - May 6, 2009 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - May 6, 2009 | Alvin Ashcraft's Morning Dew

# May 6, 2009 10:16 AM

Friday Links #50 | Blue Onion Software * said:

Pingback from  Friday Links #50 | Blue Onion Software *

# May 8, 2009 9:51 PM

Tan said:

Sorry. A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise. Help me! Help to find sites on the: Seth thomas wall clock. I found only this - <a href="wall-clock.biz/">murano glass wall clock</a>. Fine facts were sheltered, the earth of family-law appreciating to the divine of a easy research treatment to face the settings used in book, wall clock. Wall clock, it died dangerous to its former nothing - resources, and was made to scenario by the reputed review and left training lodges considered almost on algorithm. With best wishes :-), Tan from Armenia.

# March 24, 2010 6:39 PM