<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>It's the Tests</title>
	<link>http://nunit.net/blogs</link>
	<description>NUnit, TDD and the role of tests in agile development</description>
	<pubDate>Sun, 03 May 2009 07:49:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
	<language>en</language>
			<item>
		<title>Using Lambdas as Constraints in NUnit 2.5</title>
		<link>http://nunit.net/blogs/?p=67</link>
		<comments>http://nunit.net/blogs/?p=67#comments</comments>
		<pubDate>Sun, 03 May 2009 07:49:01 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=67</guid>
		<description><![CDATA[Let&#8217;s say you have an array of ints representing years, all of which should be leap years.
One way to test this would be to write a custom constraint, LeapYearConstraint. You
could then use it with the Matches syntax element to write your test as
Assert.That( array, Is.All.Matches( new LeapYearConstraint() );
But creating a new constraint for this adhoc [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you have an array of ints representing years, all of which should be leap years.</p>
<p>One way to test this would be to write a custom constraint, LeapYearConstraint. You<br />
could then use it with the Matches syntax element to write your test as</p>
<p><code style="font-size: 120%">Assert.That( array, Is.All.Matches( new LeapYearConstraint() );</code></p>
<p>But creating a new constraint for this adhoc problem seems like a bit of overkill.<br />
Instead, assuming you are working with C# version 3, try this:</p>
<p><code style="font-size: 120%">Assert.That( array, Is.All.Matches<int>( (x) => x%4 == 0 &#038;&#038; x%100 != 0 || x%400 == 0 );</code></p>
<p>If it fails, it will give a generic message: &#8220;Expected: matching lambda expression&#8221; since NUnit is actually<br />
built with .NET 2.0, but for a quick test it may be just the tool you need.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=67</wfw:commentRss>
		</item>
		<item>
		<title>Ten Reasons to Try NUnit 2,5</title>
		<link>http://nunit.net/blogs/?p=66</link>
		<comments>http://nunit.net/blogs/?p=66#comments</comments>
		<pubDate>Wed, 29 Apr 2009 18:25:24 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=66</guid>
		<description><![CDATA[NUnit 2.5 has so many new features (see the release notes) that I thought I&#8217;d try to come up with my top-ten favorites. It was hard to get down to ten, but here&#8217;s what I came up with&#8230;
Reason 1: Data-Driven Tests
Users of mbUnit and xUnit.net have enjoyed the flexibility that data-driven (aka parameteried) tests provide [...]]]></description>
			<content:encoded><![CDATA[<p>NUnit 2.5 has so many new features (see the <a href="http://nunit.org/?p=releaseNotes&amp;r=2.5">release notes</a>) that I thought I&#8217;d try to come up with my top-ten favorites. It was hard to get down to ten, but here&#8217;s what I came up with&#8230;</p>
<p><strong>Reason 1: Data-Driven Tests</strong></p>
<p>Users of mbUnit and xUnit.net have enjoyed the flexibility that data-driven (aka parameteried) tests provide for some time. NUnit implements this paradigm in its own way, with it&#8217;s own set of attributes. Test methods may have arguments and the data for them may be supplied in a number of ways: inline, from a separate method or class or randomly. This feature gives you a succinct way to express a set of examples to be used in running individual test cases.</p>
<p><b>Reason 2: Theories</b></p>
<p>As used in NUnit, a Theory is a generalized statement of how a program should operate, like &#8220;For any positive number, the square root is defined as the positive or negative number, which, when multiplied by itself, gives the original number.&#8221; Traditional, example-based, testing allows you to select one or more sets of values to use in testing such a program. A <b>Theory</b>, on the other hand, allows you to express the generalization itself, writing a test that will pass for whatever values are passed to it, provided they meet the stated constraints. David Saff has written a number of papers about the use of Theories in testing and has implemented this construct as a part of JUnit. Now you can use the same construct in any .NET language.</p>
<p><b>Reason 3: Inline Expected Exception Tests</b></p>
<p>Testing that an expected exception is thrown correctly has always been an issue in NUnit. The <b>ExpectedExceptionAttribute</b> has been available since early releases but has a number of problems. It tests that the exception was thrown somewhere in the test, without specifying the exact place in the code, and it is subject to the syntactic limitations that apply to use of an attribute. With the introduction of the <b>Assert.Throws</b> assertion method and the even more powerful constraint expressions <b>Throws.Exception</b>, <b>Throws.InstanceOf</b> and <b>Throws.TypeOf</b>, exception testing logic can now be moved right into the test along with any other necessary assertions.</p>
<p><b>Reason 4: Generic Support</p>
<p></b>NUnit 2.5 provides separate framework assemblies for .NET 1.x and 2.0+. Using .NET 2.0 or higher, a number Up to 2.4, NUnit avoided any use of Generics, in order to maintain backward compatibility. In 2.5, the framework assembly used under .NET 2.0 provides a number of generic Asserts and Constraint expressions for convenience. More significantly, your test methods and classes may now be generic, and NUnit will specialize them using the types you provide.</p>
<p><b>Reason 5: Lambda Support</b></p>
<p>If you write your tests using C# 3.0, you may use Lambda expressions in a number of places where NUnit expects a delegate. This is particularly useful in providing a custom definition of equality without explicitly defining an IComparer&lt;T&gt; and can even be used to apply an arbitrary predicate to the members of a collection.</p>
<p><b>Reason 6: Out-of-Process Execution and Runtime Selection</b></p>
<p>NUnit 2.4 ran all tests within the same process, using one or more AppDomains for isolation. This works fine for many purposes, but has some limitations. NUnit 2.5 extends this concept to running tests under one or more separate processes. Aside from the isolation it provides, this allows running the tests under a different version of the .NET runtime from the one NUnit is currently using.</p>
<p><b>Reason 7: PNUnit</b></p>
<p>PNUnit stands for &#8220;parallel NUnit&#8221; and is an extension developed by Pablo Santos Luaces and his team at <a target="_blank" href="http://codicesoftware.com">Codice Software</a> and contributed to NUnit. It&#8217;s a new way to test applications composed of distributed, communicating components. Tests of each component run in parallel and use memory barriers to synchronize their operation. Currently, pNUnit uses a special executable to launch its tests. In the future, you will be able to run pNUnit tests from the standard NUnit console or gui runner.</p>
<p><b>Reason 8: Source Code Display</b></p>
<p>The new stack trace display in the Errors and Failures tab of the Gui is able to display the source code at the location where a problem occured, provided the source is available and the program was compiled with debug information. Currently, syntax coloring for C# is provided and other languages are treated as simple text, but additional syntax definitions will be available in the future.</p>
<p><b>Reason 9: Timeout and Delayed Constraints</b></p>
<p>These are two separate features, but they are related. Besides, I&#8217;m working hard to keep this down to only ten points! It&#8217;s now possible to set a timeout, which will pre-emptively fail a test to fail if it is exceeded. This may be done on a method, fixture, assembly or as a global default. On the other hand, if you need to wait for an action to take place after a delay, you can use the After syntax to delay the application of the constraint. NUnit will subdivide a long delay and apply your test repeatedly until the constraint succeeds or the specified amount of time is up!</p>
<p><b>Reason 10: Threading Attributes</b></p>
<p>In past releases, if any test needed to run in the STA, the entire test run had to use the STA. With 2.5, any method, fixture or assembly may be given an attribute that causes it to run on a separate thread in the STA. Other attributes allow requiring an MTA or simply running on a separate thread for isolation. This can eliminate a lot of boilerplate code now required to create a separate thread, launch it and capture the results for NUnit.</p>
<p>This is my own list, of course. Yours may vary. <a target="_blank" href="http://nunit.org/?p=download#beta">Download the release</a>, try it out and let me know what your own favorites are.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=66</wfw:commentRss>
		</item>
		<item>
		<title>Code Generation in NUnit</title>
		<link>http://nunit.net/blogs/?p=65</link>
		<comments>http://nunit.net/blogs/?p=65#comments</comments>
		<pubDate>Thu, 08 Jan 2009 03:27:15 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=65</guid>
		<description><![CDATA[The latest code for NUnit 2.5 includes seven generated files, including the Assert class and most of the classes that allow you to write constraint expressions using the NUnit fluent syntax. Some people have asked if generating these files is worth the effort, since the code created is very simple anyway.
There are two reasons for [...]]]></description>
			<content:encoded><![CDATA[<p>The latest code for NUnit 2.5 includes seven generated files, including the Assert class and most of the classes that allow you to write constraint expressions using the NUnit fluent syntax. Some people have asked if generating these files is worth the effort, since the code created is very simple anyway.</p>
<p>There are two reasons for generating this code. The first relates to the syntactic constructs. While it&#8217;s relatively straight forward to create a custom constraint and various people have done so, such constraints must be used by invoking their constructors rather than by use of a simple key word. So, for example, if you have written an OddNumberConstraint that tests whether a number is odd and displays an appropriate failure message, you are still not able to write <strong>Assert.That(num, Is.Odd)</strong> without directly modifying NUnit. </p>
<p>It turns out, based on experience of several people who have tried, that the syntactic modification has a lot of places where you can go wrong. You have to modify at least three additional files, even after you have written the constraint. Using NUnit&#8217;s code generation facility, you would simply add a line like this to NUnit&#8217;s SyntaxElements.txt:</p>
<blockquote><p>Gen3: Is.Odd=>new OddConstraint()</p></blockquote>
<p>Then, after running NUnit&#8217;s code generation tool, the files Is.cs, ConstraintFactory.cs and ConstraintExpression.cs would be updated. After rebuilding NUnit - or just the framework - the statement <strong>Assert.That(num, Is.Odd)</strong> would compile and work correctly. If you wanted a classic assert, you could add the line</p>
<blockquote><p>Gen: Assert.IsOdd(int num)=>Assert.That(num, Is.Odd)</p></blockquote>
<p>and Assert.IsOdd would become available for your use, including overloads with an error message and optional arguments.</p>
<p>So, one good reason for generating code is to make it easier to extend NUnit. But an even more important reason is reliability. Take the Assert class as an example. Some of the methods have as many as 24 overloads. In the past, we have seen hidden bugs that affected only one infrequently used overload. By generating the code, we can ensure that the same logic is used in each overload. This doesn&#8217;t prevent errors, but it does make it likely that the error will be caught, since it will generally impact many of the overloads in the same way. What&#8217;s more, the layout of the SyntaxElements file puts things that need to be updated together right next to one another, so it&#8217;s much harder to forget a step.</p>
<p>The NUnit code generation program, GenSyntax.exe, is distributed with the NUnit source, in the tools directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=65</wfw:commentRss>
		</item>
		<item>
		<title>NUnit Parameteri[sz]ed Tests Reviewed</title>
		<link>http://nunit.net/blogs/?p=64</link>
		<comments>http://nunit.net/blogs/?p=64#comments</comments>
		<pubDate>Wed, 27 Aug 2008 06:37:22 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=64</guid>
		<description><![CDATA[Ben Hall has posted a nice summary of the Parameterized Test Features in NUnit 2.5 Alpha-3. Of course, being from the UK and all, he calls them Parameterised Tests.
Some of the new features are similar to approaches taken in mbUnit, about which Ben has written in past blogs. As it happens, those posts were often [...]]]></description>
			<content:encoded><![CDATA[<p>Ben Hall has posted a <a href="http://blog.benhall.me.uk/2008/08/taking-look-at-nunit-25-alpha-3.html">nice summary</a> of the Parameterized Test Features in NUnit 2.5 Alpha-3. Of course, being from the UK and all, he calls them Parameterised Tests.</p>
<p>Some of the new features are similar to approaches taken in mbUnit, about which Ben has written in past blogs. As it happens, those posts were often the best - and sometimes only - source of information I could find on how those features ought to work. So thanks for the cross-pollination you provide, Ben!</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=64</wfw:commentRss>
		</item>
		<item>
		<title>Four Ways to Test Expected Exceptions</title>
		<link>http://nunit.net/blogs/?p=63</link>
		<comments>http://nunit.net/blogs/?p=63#comments</comments>
		<pubDate>Sat, 02 Aug 2008 00:37:58 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=63</guid>
		<description><![CDATA[Let&#8217;s say we are testing a piece of code, using arguments that should cause an exception to be thrown. We want the test to ensure that an exception was thrown, that it was the expected Type of exception and - possibly - that the properties of the exception are what they should be.
In this blog, [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say we are testing a piece of code, using arguments that should cause an exception to be thrown. We want the test to ensure that an exception was thrown, that it was the expected Type of exception and - possibly - that the properties of the exception are what they should be.</p>
<p>In this blog, I&#8217;ll show how this might be done:<br />
 1. Without any support from the testing framework.<br />
 2. With a basic <strong>ExpectedException </strong>attribute<br />
 3. With a handler, as provided by NUnit 2.4<br />
 4. With a <strong>Throws.Exception</strong> constraint, as provided by NUnit 2.5</p>
<p>What I hope to show is that <strong>Throws.Exception</strong> gives us the level of control we have when we do it all ourselves, while providing a level of ease of use that is comparable to - if not better than - what we get from <strong>ExpectedExceptionAttribute</strong>.</p>
<p>First, we need an example. Let&#8217;s say that we have a method that is supposed to throw an argumentexception if the passed in argument is in an invalid state for the desired operation. Of course, this would be a pretty poor design choice in most situations, but lets just assume this is the way it has to be and that we simply need to test it.</p>
<p>Here&#8217;s the test I might write using a try/catch block.</p>
<blockquote><pre>[Test]
public void TestThatProperExceptionIsThrown()
{
  try
  {
    MethodUnderTest(anInvalidObject);
    Assert.Fail("Expected an exception, but none was thrown");
  }
  catch(ArgumentException ex)
  {
    Assert.AreEqual( ex.ParamName, "myParam" );
    Assert.AreEqual( ex.Message, "My message" );
  }
  catch(Exception ex)
  {
    Assert.Fail( "Expected an ArgumentException but got a "
      + ex.GetType().FullName );
  }
}
</pre>
</blockquote>
<p>This is somewhat tedious to write, so programmers were happy to get an <strong>ExpectedExceptionAttribute</strong> to use instead. With that support, you could write</p>
<blockquote><pre>[Test,ExpectedException(typeof(ArgumentException))]
public void TestThatProperExceptionIsThrown()
{
  MethodUnderTest(anInvalidObject);
}
</pre>
</blockquote>
<p>Or even</p>
<blockquote><pre>
[Test,ExpectedException(typeof(ArgumentException), ExpectedMessage="My message")]
public void TestThatProperExceptionIsThrown()
{
  MethodUnderTest(anInvalidObject);
}
</pre>
</blockquote>
<p>But what about ParamName? NUnit 2.4 introduced the notion of an exception handler, allowing you to write:</p>
<blockquote><pre>
[Test,ExpectedException(typeof(ArgumentException), ExpectedMessage="My message",Handler="MyHandler)]
public void TestThatProperExceptionIsThrown()
{
  MethodUnderTest(anInvalidObject);
}

public void MyHandler(Exception ex)
{
  Assert.AreEqual("myParam", ((ArgumentException)ex).ParamName);
}
</pre>
</blockquote>
<p>This gives us the functionality, but is somewhat verbose. A more serious problem is that there may be additional code in the test method, before or after the method call. This approach does not guarantee us that the exception came from a particular method.</p>
<p>NUnit 2.5 takes care of this with a new Assert and a corresponding Constraint. Assert.Throws was borrowed from the <strong>xunit.net</strong> framework, and is best for simpler cases:</p>
<blockquote><p>
Assert.Throws&lt;ArgumentException&gt;( { delegate MethodUnderTest(anInvalidObject) } );
</p></blockquote>
<p>The corresponding constraint syntax, using <strong>Throws.Exception</strong> is unique to NUnit and allows us to meet our original requrements in a single statement:</p>
<blockquote><pre>Assert.That( delegate { MethodUnderTest(anInvalidObject },
  Throws.Exception&lt;ArgumentException&#038;gt.(),
  Has.Property("ParamName").EqualTo("myParam") &#038;
  Has.Property("Message").EqualTo("My message") );
</pre>
</blockquote>
<p>For new applications, I recommend you set aside <strong>ExpectedException</strong> and use either <strong>Assert.Throws</strong> or <strong>Throws.Exception</strong>. That way, what you are testing is clearly stated right in the code, for everyone to see.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=63</wfw:commentRss>
		</item>
		<item>
		<title>NUnit&#8217;s Generic Test Fixtures</title>
		<link>http://nunit.net/blogs/?p=62</link>
		<comments>http://nunit.net/blogs/?p=62#comments</comments>
		<pubDate>Thu, 03 Jul 2008 01:16:16 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=62</guid>
		<description><![CDATA[One recent addition to NUnit 2.5 is the ability to define generic test fixtures, allowing the same fixture to be reused for multiple types that implement the same interface or even just having common method signatures. For example, the following code tests multiple implementations of IList.

[TestFixture(typeof(ArrayList))]
[TestFixture(typeof(List&#60;int&#62;))]
public class IList_Tests&#60;TList&#62; where TList : IList, new()
{
  private [...]]]></description>
			<content:encoded><![CDATA[<p>One recent addition to NUnit 2.5 is the ability to define generic test fixtures, allowing the same fixture to be reused for multiple types that implement the same interface or even just having common method signatures. For example, the following code tests multiple implementations of IList.</p>
<blockquote><pre>
[TestFixture(typeof(ArrayList))]
[TestFixture(typeof(List&lt;int&gt;))]
public class IList_Tests&lt;TList&gt; where TList : IList, new()
{
  private IList list;

  [SetUp]
  public void CreateList()
  {
    this.list = new TList();
  }

  [Test]
  public void CanAddToList()
  {
    list.Add(1); list.Add(2); list.Add(3);
    Assert.AreEqual(3, list.Count);
  }
}
</pre>
</blockquote>
<p>NUnit will create an tree branch containing two fixtures, one that uses ArrayList and another using List<int>. Combined with features like TestCase, this can be quite powerful.</p>
<p>This feature is available in the current source code and will be included in the Alpha-3 release.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=62</wfw:commentRss>
		</item>
		<item>
		<title>NUnit 2.5 and VS2008</title>
		<link>http://nunit.net/blogs/?p=61</link>
		<comments>http://nunit.net/blogs/?p=61#comments</comments>
		<pubDate>Fri, 27 Jun 2008 17:40:22 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=61</guid>
		<description><![CDATA[Thanks to a contribution from Microsoft, kindly arranged by Stephen Walther, I now have a copy of Visual Studio 2008 - and NUnit has a VS2008 build! It&#8217;s available in CVS and will be part of the Alpha-3 release in a week or two. NUnit operates pretty much on a shoestring these days, now that [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to a contribution from Microsoft, kindly arranged by Stephen Walther, I now have a copy of Visual Studio 2008 - and NUnit has a VS2008 build! It&#8217;s available in CVS and will be part of the Alpha-3 release in a week or two. NUnit operates pretty much on a shoestring these days, now that I&#8217;m semi-retired, and contributions like this help a lot.</p>
<p>As with all of NUnit&#8217;s Visual Studio builds, the VS2008 build is provided for the convenience of folks who want to build their own copy of NUnit. Our &#8220;official&#8221; releases are all built with NAnt and anyone who wants to work that way may, of course, do so themselves. Last time I checked, you could also build NUnit with one of the Express editions, so you have lots of options.</p>
<p>Currently, the VS2008 build uses .NET 2.0. I&#8217;m not envisioning a separate build for .NET 3.5 until NUnit 3.0. Of course, that could change if we come up with a good reason to change it.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=61</wfw:commentRss>
		</item>
		<item>
		<title>Parameterized Tests With NUnit 2.5</title>
		<link>http://nunit.net/blogs/?p=60</link>
		<comments>http://nunit.net/blogs/?p=60#comments</comments>
		<pubDate>Fri, 23 May 2008 17:04:18 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=60</guid>
		<description><![CDATA[It has been possible to write parameterized tests for NUnit for some time, using Andreas Schlapsi&#8217;s RowTest Extension, which recognizes the RowTest and Row attributes familiar to MbUnit users. 
With the NUnit 2.5 alpha releases, NUnit continues to support that extension - and even bundles a copy of it. But NUnit 2.5 also introduces its [...]]]></description>
			<content:encoded><![CDATA[<p>It has been possible to write parameterized tests for NUnit for some time, using Andreas Schlapsi&#8217;s <a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">RowTest Extension</a>, which recognizes the RowTest and Row attributes familiar to MbUnit users. </p>
<p>With the NUnit 2.5 alpha releases, NUnit continues to support that extension - and even bundles a copy of it. But NUnit 2.5 also introduces its own set of attributes for data-based testing, beginning with the <strong>TestCaseAttribute</strong>, which I will describe here.</p>
<p>Here&#8217;s a simple use of this new attribute&#8230;</p>
<blockquote><p>
        [TestCase(12, 3, 4)]<br />
        [TestCase(12, 2, 6)]<br />
        [TestCase(12, 4, 3)]<br />
        [TestCase(12, 0, 0, ExpectedException = typeof(System.DivideByZeroException),<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestName = &#8220;DivisionByZeroThrowsExceptionType&#8221;)]<br />
        [TestCase(12, 0, 0, ExpectedExceptionName = &#8220;System.DivideByZeroException&#8221;,<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestName = &#8220;DivisionByZeroThrowsNamedException&#8221;)]<br />
        public void IntegerDivisionWithResultPassedToTest(int n, int d, int q)<br />
        {<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Assert.AreEqual(q, n / d);<br />
        }
</p></blockquote>
<p>This creates five different test cases, displayed and reported separately. The two last tests show alternate ways to specify an expected exceptionl. Note the use of the TestName property, to specify a meaningful name for each of these cases.</p>
<p>Since this test consists of a single Assert.AreEqual statement, we can simplify it further by modifying the test method to return a result and indicate the expected result with the result property&#8230;</p>
<blockquote><p>
        [TestCase(12, 3, Result = 4)]<br />
        [TestCase(12, 2, Result = 6)]<br />
        [TestCase(12, 4, Result = 3)]<br />
        [TestCase(12, 0, ExpectedException = typeof(System.DivideByZeroException),<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestName = &#8220;DivisionByZeroThrowsExceptionType&#8221;)]<br />
        [TestCase(12, 0, ExpectedExceptionName = &#8220;System.DivideByZeroException&#8221;,<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestName = &#8220;DivisionByZeroThrowsException&#8221;)]<br />
        public int IntegerDivisionWithResultCheckedByNUnit(int n, int d)<br />
        {<br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return n / d;<br />
        }
</p></blockquote>
<p>For more information on this feature, see the <a href="http://nunit.org/?p=testCase&#038;r=2.5">NUnit documentation</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=60</wfw:commentRss>
		</item>
		<item>
		<title>NUnit 2.5 Alpha 2 Released</title>
		<link>http://nunit.net/blogs/?p=59</link>
		<comments>http://nunit.net/blogs/?p=59#comments</comments>
		<pubDate>Thu, 08 May 2008 19:02:26 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=59</guid>
		<description><![CDATA[With a European trip about to start, I decided to release a second Alpha so that the new stuff would get some visibility. I won&#8217;t be doing another release till late June, so please give this one a try.
As compared to 2.4, NUnit 2.5 has quite a lot:

Data-driven tests using [TestCase] and [DataSource]
Additional asserts and [...]]]></description>
			<content:encoded><![CDATA[<p>With a European trip about to start, I decided to release a second Alpha so that the new stuff would get some visibility. I won&#8217;t be doing another release till late June, so please <a href="http://nunit.org/?p=download">give this one a try</a>.</p>
<p>As compared to 2.4, NUnit 2.5 has quite a lot:</p>
<ul>
<li>Data-driven tests using [TestCase] and [DataSource]</li>
<li>Additional asserts and constraints, including inline exception tests.</li>
<li>Parallel and distributed testing using pNUnit.</li>
<li>Bundled addins, now including RowTest and CSUnitAddin.</li>
</ul>
<p>For more info, see the <a href="http://nunit.org/?p=releaseNotes&#038;r=2.5">release notes</a>.</p>
<p>In addition, watch the NUnit mailing lists or this blog for info about other extensions as they are released for NUnit 2.5.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=59</wfw:commentRss>
		</item>
		<item>
		<title>A Simple NUnit Usage Recipe</title>
		<link>http://nunit.net/blogs/?p=58</link>
		<comments>http://nunit.net/blogs/?p=58#comments</comments>
		<pubDate>Thu, 08 May 2008 18:49:37 +0000</pubDate>
		<dc:creator>Charlie</dc:creator>
		
		<category><![CDATA[NUnit]]></category>

		<guid isPermaLink="false">http://nunit.com/blogs/?p=58</guid>
		<description><![CDATA[Scott White has a blog about NUnit Best Practices. The approach may require adjustment on more complex projects, but it&#8217;s a very simple recipe for those starting out with NUnit.
]]></description>
			<content:encoded><![CDATA[<p>Scott White has a blog about <a href="http://scottwhite.blogspot.com/2008/05/nunit-best-practices.html">NUnit Best Practices</a>. The approach may require adjustment on more complex projects, but it&#8217;s a very simple recipe for those starting out with NUnit.</p>
]]></content:encoded>
			<wfw:commentRss>http://nunit.net/blogs/?feed=rss2&amp;p=58</wfw:commentRss>
		</item>
	</channel>
</rss>
