<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Over It. &#187; BDD</title>
	<atom:link href="http://jason.diamond.name/weblog/tag/bdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://jason.diamond.name/weblog</link>
	<description>(a Weblog by Jason Diamond)</description>
	<lastBuildDate>Mon, 30 Jan 2012 20:08:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Asserting without Equals</title>
		<link>http://jason.diamond.name/weblog/2010/10/30/asserting-without-equals/</link>
		<comments>http://jason.diamond.name/weblog/2010/10/30/asserting-without-equals/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 18:09:53 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=153</guid>
		<description><![CDATA[Arnis suggested that implementing Equals just for NUnit was wrong so I thought I&#8217;d try doing without it. The CollectionAssert.AreEqual method accepts an optional IComparer implementation. If specified, that will be used instead of Equals. So I put together a class called PartComparer. Since I switched to comparing the state of the objects outside their [...]]]></description>
			<content:encoded><![CDATA[<p>Arnis suggested that implementing <code>Equals</code> just for NUnit was wrong so I thought I&#8217;d try doing without it.</p>
<p>The <code>CollectionAssert.AreEqual</code> method accepts an optional <code>IComparer</code> implementation. If specified, that will be used instead of <code>Equals</code>.</p>
<p>So I put together a class called <code>PartComparer</code>. Since I switched to comparing the state of the objects outside their classes, I had to expose some of that state via read-only properties. I think I can live with that.</p>
<p>I then deleted all of my <code>Equals</code> and <code>GetHashCode</code> methods (I wasn&#8217;t really using <code>GetHashCode</code> anyways).</p>
<p>Here&#8217;s what the test changed to:</p>
<pre class="brush:csharp">[Test]
public void It_scans_literal_text()
{
    var scanner = new Scanner();

    var parts = scanner.Scan("foo");

    CollectionAssert.AreEqual(new Part[]
                                  {
                                      new LiteralText("foo"),
                                  },
                              parts,
                              new PartComparer());
}</pre>
<p>It works the same as before. It just requires the extra argument. </p>
<p>Custom comparers works even with the newer <code>Assert.That</code> syntax:</p>
<pre class="brush:csharp">[Test]
public void It_scans_literal_text()
{
    var scanner = new Scanner();

    var parts = scanner.Scan("foo");

    Assert.That(parts, Is.EqualTo(new Part[]
                                      {
                                          new LiteralText("foo"),
                                      })
                         .Using(new PartComparer()));
}</pre>
<p>The verbosity of constructing the expected <code>Part</code> array is a bit much. If only C# could construct lists like JavaScript, Python, and Ruby&#8230;</p>
<p>I decided to try to hide that in a custom assertion method:</p>
<pre class="brush:csharp">private static void AssertThatPartsAreEqual(
    IEnumerable&lt;Part> actualParts,
    params Part[] expectedParts)
{
    Assert.That(actualParts, Is.EqualTo(expectedParts)
                               .Using(new PartComparer()));
}</pre>
<p>Now my test looks like this:</p>
<pre class="brush:csharp">[Test]
public void It_scans_literal_text()
{
    var scanner = new Scanner();

    var parts = scanner.Scan("foo");

    AssertThatPartsAreEqual(parts, new LiteralText("foo"));
}</pre>
<p>One really nice thing about having the custom assertion method is that I can modify how parts are compared in just one spot. For example, <code>Scan</code> is really an iterator. NUnit&#8217;s failure messages when the collections aren&#8217;t arrays are less than ideal. With the comparisons being done in just one spot, I can modify it to convert the enumerable into an array:</p>
<pre class="brush:csharp">private static void AssertThatPartsAreEqual(
    IEnumerable&lt;Part> actualParts,
    params Part[] expectedParts)
{
    Assert.That(actualParts.ToArray(), Is.EqualTo(expectedParts)
                                         .Using(new PartComparer()));
}</pre>
<p>Since I&#8217;m using .NET 3.5, I can take this one step further and use an extension method:</p>
<pre class="brush:csharp">internal static class EnumerablePartExtensions
{
    public static void IsEqualTo(
        this IEnumerable&lt;Part> actualParts,
        params Part[] expectedParts)
    {
        Assert.That(actualParts.ToArray(), Is.EqualTo(expectedParts)
                                             .Using(new PartComparer()));
    }
}</pre>
<p>With that in place, my test now looks like this:</p>
<pre class="brush:csharp">[Test]
public void It_scans_literal_text()
{
    var scanner = new Scanner();

    var parts = scanner.Scan("foo");

    parts.IsEqualTo(new LiteralText("foo"));
}</pre>
<p>Wow, it&#8217;s like Ruby but without the monkey patching!</p>
<p>One thing I did leave in my code are all of the <code>ToString</code> overrides. Without those, NUnit&#8217;s failure messages would be much less helpful. They&#8217;re also very useful while debugging.</p>
<p>Thanks, Arnis. Your comment helped me find an alternative (and quite possibly better!) way to get what I want.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2010/10/30/asserting-without-equals/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I fail at TDD?</title>
		<link>http://jason.diamond.name/weblog/2010/10/29/i-fail-at-tdd/</link>
		<comments>http://jason.diamond.name/weblog/2010/10/29/i-fail-at-tdd/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 21:57:51 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=129</guid>
		<description><![CDATA[I actually think I&#8217;m pretty good at TDD. Every now and then I get reminded that I&#8217;m not as good as I think I am. I&#8217;ve been working on a new project (an implementation of the Mustache template language in C# that I&#8217;m calling Nustache) and have been having a lot of fun with it. [...]]]></description>
			<content:encoded><![CDATA[<p>I actually think I&#8217;m pretty good at TDD. Every now and then I get reminded that I&#8217;m not as good as I think I am.</p>
<p>I&#8217;ve been working on a new project (an implementation of the <a href="http://mustache.github.com/">Mustache</a> template language in C# that I&#8217;m calling <a href="http://github.com/jdiamond/Nustache">Nustache</a>) and have been having a lot of fun with it. This is the project I&#8217;m going to use as an example of how I fail at TDD.</p>
<p>Since this project involves parsing a string, I decided I would probably need a class to scan the string for tokens so those tokens could be parsed and then evaluated.</p>
<p>While writing the test for my <code>Scanner</code> class, I wrote it so that it would assert on the sequence of tokens it returns. I decided the tokens would be instances of a class called <code>Part</code>. One specific subclass of <code>Part</code> would be <code>LiteralText</code>. It represents a span of characters from the source template that is <em>not</em> supposed to be evaluated and just rendered directly to the output. I figured this would be the easiest way to start testing my <code>Scanner</code> class.</p>
<p>The test probably looked like this (I&#8217;m writing this way after the fact):</p>
<pre class="brush:csharp">[Test]
public void It_scans_literal_text()
{
    var scanner = new Scanner();

    var parts = scanner.Scan("foo");

    CollectionAssert.AreEqual(new Part[]
                              {
                                  new LiteralText("foo"),
                              },
                              parts);
}</pre>
<p>At this point, the test didn&#8217;t compile because I hadn&#8217;t defined my <code>Scanner</code>, <code>Part</code>, and <code>LiteralText</code> classes yet.</p>
<p>Having written the test first, I learned a few things about the <code>Scanner</code> class it was trying to test:</p>
<ul>
<li>It has a default constructor</li>
<li>It has a method named <code>Scan</code></li>
<li>Its <code>Scan</code> method takes in a string</li>
<li>Its <code>Scan</code> method returns an <code>IEnumerable&lt;Part></code> (I know this because of the parameters for <code>CollectionAssert.AreEqual</code>)</li>
</ul>
<p>I also learned something about the <code>LiteralText</code> class:</p>
<ul>
<li>It derives from <code>Part</code> (because I&#8217;m adding it to a <code>Part</code> array)</li>
<li>It has a constructor that accepts a string</li>
<li>It must override the <code>Equals</code> method or this will never work</li>
</ul>
<p>Since this test is describing the <code>Scanner</code> class, I decided to work on it first:</p>
<pre class="brush:csharp">public class Scanner
{
    public IEnumerable&lt;Part> Scan(string template)
    {
       return null;
    }
}</pre>
<p>This wouldn&#8217;t compile until I defined <code>Part</code>:</p>
<pre class="brush:csharp">public class Part
{
}</pre>
<p>The test still needed <code>LiteralText</code> to be defined:</p>
<pre class="brush:csharp">public class LiteralText : Part
{
    public LiteralText(string text)
    {
    }
}</pre>
<p>At this point, I was able to compile and run my test. When I did, NUnit said this:</p>
<pre>Test 'Nustache.Tests.Describe_Scanner_Scan.It_scans_literal_text' failed:
  Expected: &lt; &lt;Nustache.Core.LiteralText> >
  But was:  null</pre>
<p>I liked that failure message, but I wanted to go a bit further and see what the failure message would be when I return an empty array instead of <code>null</code> since it didn&#8217;t make sense to me for <code>Scan</code> to return <code>null</code>. <code>Scan</code> changed to this:</p>
<pre class="brush:csharp">public IEnumerable&lt;Part> Scan(string template)
{
    return new Part[] { };
}</pre>
<p>The failure message became this:</p>
<pre>Test 'Nustache.Tests.Describe_Scanner_Scan.It_scans_literal_text' failed:
  Expected is &lt;Nustache.Core.Part[1]>, actual is &lt;Nustache.Core.Part[0]>
  Values differ at index [0]
  Missing:  &lt; &lt;Nustache.Core.LiteralText> >
</pre>
<p>OK, that wasn&#8217;t too bad. Next, I wanted to see if I could get it to pass by doing the simplest thing I could possibly do so I changed <code>Scan</code> to this:</p>
<pre class="brush:csharp">public IEnumerable<Part> Scan(string template)
{
    return new Part[]
               {
                   new LiteralText("foo")
               };
}</pre>
<p>After seeing that pass, I would have implemented it a little more realistically, but I was in for a surprise. Instead of passing (which is what I expected), I got this failure message:</p>
<pre>Test 'Nustache.Tests.Describe_Scanner_Scan.It_scans_literal_text' failed:
  Expected and actual are both &lt;Nustache.Core.Part[1]>
  Values differ at index [0]
  Expected: &lt;Nustache.Core.LiteralText>
  But was:  &lt;Nustache.Core.LiteralText></pre>
<p>Uh&#8230; Oh, yeah! <code>LiteralText</code> needs an override of the <code>Equals</code> method or NUnit will never be able to tell if one instance is &#8220;equal to&#8221; another.</p>
<p>In order to implement that, I need to make sure the string that gets passed in to the <code>LiteralText</code> constructor gets saved in some sort of field or property. Then I could write my <code>Equals</code> override by hand or let ReSharper generate it for me.</p>
<p>I decided to let ReSharper do it (I&#8217;m lazy) and got three methods: <code>bool Equals(LiteralText other)</code>, <code>bool Equals(object obj)</code>, and <code>int GetHashCode()</code>.</p>
<p>After getting that to work, I added a <code>ToString</code> method to <code>LiteralText</code> to make the failure message even clearer.</p>
<p>See the problem? I went off and started implementing code in <code>LiteralText</code> when I was in the middle of trying to get a test for <code>Scanner</code> to pass! Sure, it&#8217;s <em>just</em> the <code>Equals</code> and <code>GetHashCode</code> methods, but it&#8217;s still code!</p>
<p>I did all of this in response to test I was trying to get to pass so I was still doing TDD, right?</p>
<p>Right?</p>
<p>At the time I was doing this, I didn&#8217;t even notice this &#8220;problem&#8221;. It wasn&#8217;t until much later when I decided to run my tests under NCover to see how I was doing. I was practicing TDD, so my coverage should have been pretty good, if not perfect. Sadly, I found I had a bunch of <code>Equals</code>, <code>GetHashCode</code>, and <code>ToString</code> methods that weren&#8217;t fully covered and ruining my flawless code coverage report!</p>
<p>So what&#8217;s the big deal? Everybody agrees that 100% code coverage isn&#8217;t sufficient to ensure the correctness of your code. I absolutely agree with that. Many people also agree that getting 100% code coverage isn&#8217;t even worth it. That, I disagree with. As does Patrick Smacchia (author of <a href="http://www.ndepend.com/">NDepend</a>) who described why 100% code coverage is a worthwhile goal <a href="http://codebetter.com/blogs/patricksmacchia/archive/2009/06/07/high-test-coverage-ratio-is-a-good-thing-anyway.aspx">here</a>. It&#8217;s a great article and I highly recommend you all read it.</p>
<p>To rectify this predicament, I forced myself to write tests for my <code>LiteralText</code> class (writing tests after the fact is so boring!).</p>
<p>Since I originally defined it, I discovered that <code>Part</code> had grown a <code>Render</code> method and <code>LiteralText</code> was overriding it. The method was being covered by other tests, but there was nothing that was <em>directly</em> testing <code>LiteralText</code>. That might not be such a big deal, but one of the oft-touted benefits of unit tests is that they can also act as <em>executable documentation</em>. Since I had no unit tests for my <code>LiteralText</code> class, I had no executable documentation for it! How would I ever re-learn (months from now) how it&#8217;s supposed to behave without that?</p>
<p>OK, I&#8217;m being a bit silly, but I went for it anyways and I really liked the result. Here&#8217;s what I came up with:</p>
<pre class="brush:csharp">[TestFixture]
public class Describe_LiteralText
{
    [Test]
    public void It_cant_be_constructed_with_null_text()
    {
        Assert.Throws&lt;ArgumentNullException>(() => new LiteralText(null));
    }

    [Test]
    public void It_renders_its_text()
    {
        var a = new LiteralText("a");
        var writer = new StringWriter();
        var context = new RenderContext(null, null, writer, null);

        a.Render(context);

        Assert.AreEqual("a", writer.GetStringBuilder().ToString());
    }

    [Test]
    public void It_has_a_useful_Equals_method()
    {
        object a = new LiteralText("a");
        object a2 = new LiteralText("a");
        object b = new LiteralText("b");

        Assert.IsTrue(a.Equals(a));
        Assert.IsTrue(a.Equals(a2));
        Assert.IsTrue(a2.Equals(a));
        Assert.IsFalse(a.Equals(b));
        Assert.IsFalse(a.Equals(null));
        Assert.IsFalse(a.Equals("a"));
    }

    [Test]
    public void It_has_an_Equals_overload_for_other_LiteralText_objects()
    {
        var a = new LiteralText("a");
        var a2 = new LiteralText("a");
        var b = new LiteralText("b");

        Assert.IsTrue(a.Equals(a));
        Assert.IsTrue(a.Equals(a2));
        Assert.IsTrue(a2.Equals(a));
        Assert.IsFalse(a.Equals(b));
        Assert.IsFalse(b.Equals(a));
        Assert.IsFalse(a.Equals(null));
    }

    [Test]
    public void It_has_a_useful_GetHashCode_method()
    {
        var a = new LiteralText("a");

        Assert.AreNotEqual(0, a.GetHashCode());
    }

    [Test]
    public void It_has_a_useful_ToString_method()
    {
        var a = new LiteralText("a");

        Assert.AreEqual("LiteralText(\"a\")", a.ToString());
    }
}</pre>
<p>As you can probably tell, I&#8217;m using a non-standard (for .NET developers) naming scheme for my tests. It&#8217;s inspired by <a href="http://rspec.info/">RSpec</a> and I really like it.</p>
<p>If you take away all the code, the ugly underscores, and the weird prefixes, you get the documentation:</p>
<ul>
<li>LiteralText</li>
<ul>
<li>can&#8217;t be constructed with null text</li>
<li>renders its text</li>
<li>has a useful Equals method</li>
<li>has an Equals overload for other LiteralText objects</li>
<li>has a useful GetHashCode method</li>
<li>has a useful ToString method</li>
</ul>
</ul>
<p>Could that get any clearer? (Seriously, leave a comment if you think it could.)</p>
<p>I formatted that list by hand, but generating it could easily be automated by processing NUnit&#8217;s XML output or using reflection on the test assembly. RSpec has a feature built in to it that can generate this kind of output. (Don&#8217;t worry, I don&#8217;t plan on switching to Ruby like every other .NET weblogger out there seems to be doing. I do think they have some great ideas, though, and have been really enjoying reading the beta version of the <a href="http://www.pragprog.com/titles/achbd/the-rspec-book">RSpec Book</a> which is what made me try out this new naming scheme.)</p>
<p>Even though this particular class is trivial, doing this helped set up an example to follow for the other <code>Part</code> subclasses which aren&#8217;t as simple. Also, I feel much more confident about this class knowing that there is a suite of tests in a single, well-named fixture that provides 100% code coverage for it.</p>
<p>I&#8217;m not saying that every class should be covered by one and only one fixture. If the class demands it, I&#8217;ll happily break its tests up into multiple fixtures. I could have one fixture per method or one fixture per context. I&#8217;m flexible about that. I&#8217;d use the desire to that as a possible smell that the class might be trying to do too much, though.</p>
<p>You can also see that I&#8217;m pretty flexible about not limiting myself to just <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=35578">one assertion per test</a>. I strongly believe that most tests should only have one assertion but, in this case, it would have been ridiculous to have written a test case for each of the different ways <code>Equals</code> could be invoked.</p>
<p>I was also a little lax on the <a href="http://c2.com/cgi/wiki?ArrangeActAssert">Arrange/Act/Assert</a> format. This is another practice that I try to consistently follow. Some tests just don&#8217;t need anything to be set up! And NUnit&#8217;s <code>Assert.Throws</code> syntax kind of forces you to act and assert at the same time. There&#8217;s not a lot I can do about that.</p>
<p>Here&#8217;s the one thing that I&#8217;m firm on: Ensuring that I have a set of tests that fully cover 100% of the unit that they <em>directly</em> test is a <strong>Good Thing</strong>.</p>
<p>And here&#8217;s the million dollar question: What can I do to prevent these kinds of mistakes in the future? Is it even possible?</p>
<p>To be honest, I&#8217;m OK making mistakes as long as I can catch and fix them quickly enough. Did I know about the <code>Part</code> and <code>LiteralText</code> classes before starting work on <code>Scanner</code>? I can&#8217;t actually remember. Let&#8217;s pretend I didn&#8217;t. As soon as I saw that the test for <code>Scanner</code> was referencing other classes, should I have stopped what I was doing, put an <code>Ignore</code> attribute on the test, and started working on tests for those other classes first? I&#8217;m not so sure about that. I feel like doing that might have negatively impacted the journey I had already embarked on.</p>
<p>So maybe &#8220;failing&#8221; at TDD in this way is expected? It&#8217;s rare when a class has no dependencies. If I&#8217;m using tools like NUnit, NCover, and NDepend, I should be able to catch my &#8220;mistakes&#8221; pretty quickly. This means that my unit tests have to be <em>fast</em> or I&#8217;ll rarely run them and, if that happens, my mistakes won&#8217;t be caught until much later. By that point, I&#8217;ll have too many mistakes to fix, I&#8217;ll be out of time, forced to move on to the next task, and, there I go, abandoning everything I believe in (about developing and testing)!</p>
<p>And my coworkers wonder why I hate our &#8220;unit tests&#8221; that read from and write to the database so much&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2010/10/29/i-fail-at-tdd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New BehaveN Release</title>
		<link>http://jason.diamond.name/weblog/2010/09/03/new-behaven-release/</link>
		<comments>http://jason.diamond.name/weblog/2010/09/03/new-behaven-release/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 23:59:05 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[BehaveN]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=113</guid>
		<description><![CDATA[This is a minor, bug fix release. You can see the changes here. I&#8217;ve also updated the wiki with some more documentation.]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/behaven/downloads/detail?name=BehaveN-2.0.1.102.zip">This</a> is a minor, bug fix release. You can see the changes <a href="http://code.google.com/p/behaven/source/browse/HISTORY.txt?spec=svnd804cddd71ef23bd7254c9f018ce3264cf12d343&#038;r=d804cddd71ef23bd7254c9f018ce3264cf12d343">here</a>.</p>
<p>I&#8217;ve also updated the <a href="http://code.google.com/p/behaven/w/list">wiki</a> with some more documentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2010/09/03/new-behaven-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BehaveN</title>
		<link>http://jason.diamond.name/weblog/2010/07/11/behaven/</link>
		<comments>http://jason.diamond.name/weblog/2010/07/11/behaven/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 00:58:14 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[BehaveN]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=110</guid>
		<description><![CDATA[I&#8217;ve been using a Cucumber-inspired BDD framework for .NET called BehaveN at work for the past year. Today, I just released the next major version. There&#8217;s a little documentation on the wiki, including a tutorial, but there&#8217;s a lot left that I haven&#8217;t documented yet. I&#8217;ll be getting more and more documentation up as time [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using a <a href="http://cukes.info/">Cucumber</a>-inspired BDD framework for .NET called <a href="http://code.google.com/p/behaven/">BehaveN</a> at work for the past year. Today, I just released the next major version.</p>
<p>There&#8217;s a little documentation on the wiki, including a <a href="http://code.google.com/p/behaven/wiki/Tutorial">tutorial</a>, but there&#8217;s a lot left that I haven&#8217;t documented yet. I&#8217;ll be getting more and more documentation up as time goes on.</p>
<p>It&#8217;s been pretty positively received by our product owners, QA, and most of the developers who&#8217;ve been exposed to it. It&#8217;s being used by a few outside my company, but I haven&#8217;t made any effort on &#8220;advertising&#8221; it. If anybody&#8217;s interested in giving it a try, let me know and I&#8217;ll try to fill in any of the blanks you might have.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2010/07/11/behaven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoRunner Downloads</title>
		<link>http://jason.diamond.name/weblog/2009/09/28/autorunner-downloads/</link>
		<comments>http://jason.diamond.name/weblog/2009/09/28/autorunner-downloads/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 04:23:06 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[AutoRunner]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=75</guid>
		<description><![CDATA[I took some time tonight to throw together a build script for producing proper releases of AutoRunner. If you don&#8217;t feel like compiling it yourself, you can get a pre-compiled version here. I used ILMerge to merge the Growl for Windows assemblies into the executable so it&#8217;s basically a single file now. By the way, [...]]]></description>
			<content:encoded><![CDATA[<p>I took some time tonight to throw together a build script for producing proper releases of <a href="http://github.com/jdiamond/autorunner">AutoRunner</a>. If you don&#8217;t feel like compiling it yourself, you can get a pre-compiled version <a href="http://github.com/jdiamond/autorunner/downloads">here</a>.</p>
<p>I used <a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx">ILMerge</a> to merge the <a href="http://www.growlforwindows.com/">Growl for Windows</a> assemblies into the executable so it&#8217;s basically a single file now.</p>
<p>By the way, last night on Twitter, <a href="http://blog.unhandled-exceptions.com/">Steve Bohlen</a> pointed me to <a href="http://averyblog.com/net/announcing-autotest-net-0-1/">this port of the original autotest to .NET</a>. I took a look at the code and it was much more complex than I was looking for. It actually builds and runs your tests every time you save which is much more often than I want.</p>
<p>I had AutoRunner turned on all day at work today and was loving how it would catch me breaking the tests when I wasn&#8217;t expecting it to. =)</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2009/09/28/autorunner-downloads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoRunner</title>
		<link>http://jason.diamond.name/weblog/2009/09/27/autorunner/</link>
		<comments>http://jason.diamond.name/weblog/2009/09/27/autorunner/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 23:13:28 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[AutoRunner]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=66</guid>
		<description><![CDATA[I recently came across this awesome code kata performance by Corey Haines here. Besides enjoying and learning from his actual performance, I was really impressed by his use of a Ruby tool called autotest. (I&#8217;m not sure, but it looks like it has become autospec.) Not being a Ruby developer, I wanted the same thing [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across this awesome code kata performance by Corey Haines <a href="http://charlesmaxwood.com/8-lessons-from-corey-haines-performance-kata/">here</a>.</p>
<p>Besides enjoying and learning from his actual performance, I was really impressed by his use of a Ruby tool called <a href="http://ph7spot.com/articles/getting_started_with_autotest">autotest</a>. (I&#8217;m not sure, but it looks like it has become <a href="http://www.nateclark.com/articles/2008/09/17/_autotest_-is-now-_autospec_-how-to-set-up-autospec-for-rspec-and-rails-with-zentest">autospec</a>.)</p>
<p>Not being a Ruby developer, I wanted the same thing for .NET. I did some searching, but my Google-fu failed me so I spent an hour hacking together my own.</p>
<p>The result is called <a href="http://github.com/jdiamond/autorunner">AutoRunner</a> (I know&#8211;way creative) and its source is available on GitHub.</p>
<p>If you want it, you have to download the source and compile it yourself for now. (UPDATE: You can now download it <a href="http://github.com/jdiamond/autorunner/downloads">here</a>!) Run it from your favorite console (PowerShell, right?) without any arguments to see what options it accepts.</p>
<p>AutoRunner is a little more general purpose than autotest/autospec is. Basically, it can run any executable when any file changes.</p>
<p>What I wanted it for was to run nunit-console.exe whenever my current tests assembly was rebuilt. To do that, I just invoke it with the right arguments.</p>
<p>If you have <a href="http://www.growlforwindows.com/">Growl for Windows</a> running, it will send it a notification which is pure eye candy and not necessary to actually get it to run your tests.</p>
<p>It&#8217;s not a Visual Studio add-in. It&#8217;s just a plain old console application. Using Visual Studio&#8217;s External Tools feature, however, it&#8217;s almost as good as an add-in. I set up an external tool with the appropriate arguments and it&#8217;s good to go for all of my projects.</p>
<p>To set this up for yourself, you&#8217;d create a new external tool with its command set to the path where you built AutoRunner.exe and its arguments set to something like the following (I&#8217;ve separated the options on their own lines, but you wouldn&#8217;t do that in Visual Studio):</p>
<pre>--target $(BinDir)\$(TargetName)$(TargetExt)
--exe C:\path\to\nunit-console.exe
--pass "$(TargetName) FTW!"
--fail "Oh noes! $(TargetName) is FAIL!"</pre>
<p>You can use whatever test runner you like, of course. Please note that you must have a file from your tests project open or selected in Solution Explorer when you activate the tool or your AutoRunner instance will be watching the wrong DLL!</p>
<p>It doesn&#8217;t support plug-ins the way autotest does and most of its functionality is hard-coded for now. If anybody finds it useful, let me know and maybe we can work on improving it together.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2009/09/27/autorunner/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SharpTestsEx</title>
		<link>http://jason.diamond.name/weblog/2009/09/26/sharptestsex/</link>
		<comments>http://jason.diamond.name/weblog/2009/09/26/sharptestsex/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 23:12:10 +0000</pubDate>
		<dc:creator>Jason Diamond</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[TDD]]></category>

		<guid isPermaLink="false">http://jason.diamond.name/weblog/?p=61</guid>
		<description><![CDATA[I&#8217;ve been using Fabio Maulo&#8216;s NUnitEx project to get fluent assertions on a personal project recently and have been loving it. He then went and moved on to a new project called SharpTestsEx, which he intended to be framework-agnostic, but currently only worked with MSTest which prevented me from being able to use it (since [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://fabiomaulo.blogspot.com/">Fabio Maulo</a>&#8216;s <a href="http://code.google.com/p/nunitex/">NUnitEx</a> project to get fluent assertions on a personal project recently and have been loving it.</p>
<p>He then went and moved on to a new project called <a href="http://sharptestex.codeplex.com/">SharpTestsEx</a>, which he intended to be framework-agnostic, but currently only worked with MSTest which prevented me from being able to use it (since I never saw a compelling reason to switch to MSTest).</p>
<p>Fabio was kind enough to let me make the changes necessary to remove the dependency on MSTest. A also made framework-specific versions of SharpTestsEx for MSTest, NUnit, and xUnit. The framework-specific versions aren&#8217;t really necessary, but they make the error messages a tiny bit prettier if you use the right one for the test framework you&#8217;re using.</p>
<p>You can read Fabio&#8217;s announcement <a href="http://fabiomaulo.blogspot.com/2009/09/sharp-tests-ex-030-fluent-and-lambda.html">here</a>.</p>
<p>I plan on updating my personal project to using SharpTestsEx next.</p>
<p>I just realized I never posted about that project; I&#8217;ll have to get around to that soon. If you&#8217;re curious, it&#8217;s a <a href="http://dannorth.net/introducing-bdd">behaviour-driven development</a> framework for .NET called <a href="http://code.google.com/p/behaven/">BehaveN</a>. I&#8217;m using it at my work and we&#8217;re loving it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jason.diamond.name/weblog/2009/09/26/sharptestsex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

