<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.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>Makiwa &#187; Agile Development</title>
	<link>http://www.makiwa.com</link>
	<description>Stuart Campbell's occasional musings about software development, etc.</description>
	<pubDate>Thu, 08 May 2008 11:04:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Visual Studio and the Evil Unit Test Wizard</title>
		<link>http://www.makiwa.com/index.php/2006/07/16/visual-studio-and-the-evil-unit-test-wizard/</link>
		<comments>http://www.makiwa.com/index.php/2006/07/16/visual-studio-and-the-evil-unit-test-wizard/#comments</comments>
		<pubDate>Sun, 16 Jul 2006 22:44:44 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[Agile Development]]></category>

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

		<category><![CDATA[Extreme Programming]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2006/07/16/visual-studio-and-the-evil-unit-test-wizard/</guid>
		<description><![CDATA[I fancy a bit of rant. And today&#8217;s punchbag is Visual Studio&#8217;s Unit Test Wizard.

&#60;rant&#62;
It is evil and it should be dropped from the product.
My previous company outsourced the development of a software project and I ended up reviewing the code from the first iteration. I had concerns about some of the code; one concern [...]]]></description>
			<content:encoded><![CDATA[<p>I fancy a bit of rant. And today&#8217;s punchbag is Visual Studio&#8217;s Unit Test Wizard.<br />
<div style="font-family:Courier New; white-space:pre-wrap;"><br />
&lt;rant&gt;<br /></div><br />
It is evil and it should be dropped from the product.</p>
<p>My previous company outsourced the development of a software project and I ended up reviewing the code from the first iteration. I had concerns about some of the code; one concern was that they had used Visual Studio&#8217;s Unit Test Wizard to auto-generate their unit tests.</p>
<p>There areÂ three main reasons I dislike this feature.</p>
<ol>
<li><strong>Discourages test-driven development</strong><br />
There is a growing consensus that test-driven development results in better tests, better code coverage, higher quality code, and more productive development. Visual Studio&#8217;s auto-generation of test methods discourages such a test-driven approach, as it requires the code to have been written before the tests are generated.</li>
<li><strong>Causes method-centric tests</strong><br />
Auto-generation of test methods results in tests that are <em>method-centric</em> rather than <em>requirement-centric</em>. The issue with auto-generated, method-centric tests is that a) they don&#8217;t have descriptive names, and b) they promote the belief that if you write a test that calls that method then it is &#8220;covered&#8221; - regardless of how many branches there are in the logic of the method.</li>
<li><strong>Creates homogenous tests</strong><br />
I believe that the unit tests shouldÂ be a collection of &#8220;little stories&#8221; that describe the system. But auto-generated tests all look the same. They don&#8217;t give you a good feel for what a system does because each one is just the setup for a method call and the evaluation of the result. To paraphrase Groove Armada, if every test looks the same, you get tired of looking at them!</li>
<li><strong>Causes test fatigue and weak tests</strong><br />
This is perhaps the biggest problem with the tool and it results from not using a test-driven approach. Once Visual Studio has kindly generated, say, 50 test method stubs, the developer is faced with the task of &#8220;filling them all in&#8221;. In my opinion, these tests are likely to be weak. Not only because the developer is temporally disconnected from the spirit and nuances of the various underlying requirements than he would have been with a test-first approach. But he now has a mammoth task ahead of him. By the time he hits test #15 he is going to be suffering from &#8220;test fatigue&#8221; and is very likely to start compromising on test quality to just get it over and done with.
</li>
</ol>
<p>I&#8217;m not saying that ALL unit tests developed with this wizard are necessarily flawed. I&#8217;m just saying that it <em>increases the liklihood of poor quality tests</em>. And poor quality tests are perhaps more dangerous than no tests&#8230;&#8221;I ran the Unit Test Wizard, filled in the blanks, did some refactoring. Whadya know! All the tests pass&#8230;RELEASE IT!</p>
<p>I&#8217;d like to consign this feature to the dustbin.<br />
<div style="font-family:Courier New; white-space:pre-wrap;"><br />
&lt;/rant&gt;<br /></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2006/07/16/visual-studio-and-the-evil-unit-test-wizard/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Return of the waterfall&#8230;not</title>
		<link>http://www.makiwa.com/index.php/2006/02/16/return-of-the-waterfallnot/</link>
		<comments>http://www.makiwa.com/index.php/2006/02/16/return-of-the-waterfallnot/#comments</comments>
		<pubDate>Thu, 16 Feb 2006 14:32:30 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[Agile Development]]></category>

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

		<guid isPermaLink="false">http://www.makiwa.com/index.php/2006/02/16/return-of-the-waterfallnot/</guid>
		<description><![CDATA[If you&#8217;ve had any exposure to software development methodologies then you&#8217;ll love this spoof conference website&#8230;Waterfall 2006
After years of being disparaged by some in the software development community, the waterfall process is back with a vengeance. You&#8217;ve always known a good waterfall-based process is the right way to develop software projects. Come to the Waterfall [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve had any exposure to software development methodologies then you&#8217;ll love this spoof conference website&#8230;<a href="http://www.waterfall2006.com/">Waterfall 2006</a></p>
<blockquote><p>After years of being disparaged by some in the software development community, the waterfall process is back with a vengeance. You&#8217;ve always known a good waterfall-based process is the right way to develop software projects. Come to the Waterfall 2006 conference and see how a sequential development process can benefit your next project. Learn how slow, deliberate handoffs (with signatures!) between groups can slow the rate of change on any project so that development teams have more time to spend on anticipating user needs through big, upfront design.</p></blockquote>
<p>Heheheh</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2006/02/16/return-of-the-waterfallnot/feed/</wfw:commentRss>
		</item>
		<item>
		<title>NUnit and Visual Studio 2005 Beta 2</title>
		<link>http://www.makiwa.com/index.php/2005/08/11/nunit-and-visual-studio-2005-beta-2/</link>
		<comments>http://www.makiwa.com/index.php/2005/08/11/nunit-and-visual-studio-2005-beta-2/#comments</comments>
		<pubDate>Thu, 11 Aug 2005 14:27:13 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[Agile Development]]></category>

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

		<category><![CDATA[Extreme Programming]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/?p=31</guid>
		<description><![CDATA[I was struggling to get NUnit 2.2 to work with a VS2005 Beta 2 project. I kept getting a BadImageFormatException when I tried to launch NUnit-GUI.exe.
The solution was to add the following line to the &#60;startup&#62; tag of nunit-gui.exe.config (and nunit-console.exe.config if you are using it from the command line):
&#60;supportedRuntime version=&#8221;v2.0.50215&#8221; /&#62;
EDIT: For the final [...]]]></description>
			<content:encoded><![CDATA[<p>I was struggling to get <a href="http://www.nunit.org">NUnit</a> 2.2 to work with a VS2005 Beta 2 project. I kept getting a BadImageFormatException when I tried to launch NUnit-GUI.exe.</p>
<p>The solution was to add the following line to the &lt;startup&gt; tag of nunit-gui.exe.config (and nunit-console.exe.config if you are using it from the command line):</p>
<div style="font-family: Courier New">&lt;supportedRuntime <span class="mcsh_red;">version</span><span class="mcsh_red;" />=&#8221;<span class="mcsh_blue">v2.0.50215</span>&#8221; /&gt;</div>
<p><strong>EDIT:</strong> For the final release of Visual StudioÂ 2005 you would of course use:</p>
<div style="font-family: Courier New">&lt;supportedRuntime <span class="mcsh_red;">version</span><span class="mcsh_red;" />=&#8221;<span class="mcsh_blue">v2.0.50727</span>&#8221; /&gt;</div>
<p>You may need to comment out all the other <em>supportedRuntime</em> entries to get it to work.</p>
<p>Having got NUnit to test a .NET v2.0 assembly, my next task was to get it working as the debug harness for my class library projects <a href="http://www.makiwa.com/index.php/2005/08/02/test-driving-class-libraries-with-nunit-and-visual-studio-2003/">like I did with Visual Studio 2003</a>.</p>
<p>I was quite hopeful. I did everything as I had done for my VS 2003 projectsâ€¦but no - they NUnit and VS2005 did not want to play nicely together! When I ran the project, NUnit did launch, but when I clicked â€œRunâ€ nothing happened.</p>
<p>I spend a couple of hours trying to get it to work but to no avail. Eventually, out of desperation I downloaded the latest iteration build of NUnit (version 2.2.2 as of this writing). I set the 2.2.2 version of nunit-console.exe to be the startup program (remembering to update its config file with the â€œsupportedRuntimeâ€ stuff mentioned above)â€¦and voilÃ ! It works a treat!</p>
<p>So if you canâ€™t get NUnit to work with VS 2005 - try to download the latest drop from <a href="http://www.nunit.org/download.html" target="_blank">http://www.nunit.org/download.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2005/08/11/nunit-and-visual-studio-2005-beta-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Test driving class libraries with NUnit and Visual Studio 2003</title>
		<link>http://www.makiwa.com/index.php/2005/08/02/test-driving-class-libraries-with-nunit-and-visual-studio-2003/</link>
		<comments>http://www.makiwa.com/index.php/2005/08/02/test-driving-class-libraries-with-nunit-and-visual-studio-2003/#comments</comments>
		<pubDate>Tue, 02 Aug 2005 18:42:13 +0000</pubDate>
		<dc:creator>Stu</dc:creator>
		
		<category><![CDATA[Agile Development]]></category>

		<category><![CDATA[Extreme Programming]]></category>

		<guid isPermaLink="false">http://www.makiwa.com/?p=30</guid>
		<description><![CDATA[Recently, I was developing a class library project in Visual Studio 2003. I wanted to do Test Driven Development with NUnit, and use NUnit as the debug harness for my library. I tried several approaches but none of them seemed to work well for me. 
My main requirements were that:

It should be version control friendly [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I was developing a class library project in Visual Studio 2003. I wanted to do Test Driven Development with NUnit, and use NUnit as the debug harness for my library. I tried several approaches but none of them seemed to work well for me. </p>
<p>My main requirements were that:</p>
<ol>
<li>It should be version control friendly (shouldnâ€™t require additional setup steps after checking it out from version control â€“ it should just work).</li>
<li>You should be able to debug the class library by setting one or more breakpoints and then just running a test.</li>
</ol>
<p>Fortunately, perseverance has triumphed over ineptitude and I have come up with a solution.</p>
<p>What follows is a step-by-step guide to setting it all up.<br />
<a id="more-32"></a></p>
<ol>
<li><strong>Install NUnit</strong><br />
I am currently using NUnit 2.2. Download a copy from the NUnit website (<a target="_blank" href="http://www.nunit.org/">www.nunit.org</a>) and install it.</li>
<li><strong> Create a blank solution</strong><br />
By creating a blank solution first and then adding the project, you don&#8217;t end up with the solution and project files in the same place. This isn&#8217;t critical but it helps if you ever add other projects. That way your solution file will be in the logical place - the folder above all of the projects.</p>
<p>I created Solution1.sln in a folder called Solution1.</li>
<li><strong>Add a new Class Library project to that solution.</strong>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/01-initial-project.gif" alt="Initial project" /></li>
<li><strong>Add a test class</strong><br />
Add a new class called Class1Tests.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/02-add-test-class.gif" alt="Add a test class" /></li>
<li><strong>Add a reference to NUnit framework</strong>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/03b-add-ref.gif" alt="Add reference to NUnit framework" /></li>
<li><strong>Add a new test</strong><br />
In Class1Tests.cs you need to add a using statement (NUnit.Framework).<br />
You should then add a [TestFixture] attribute to the class.<br />
Now create a stub test method: CreateClass1. This new method needs a [Test] attribute.</p>
<p>You can now build the project.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/04-create-test.gif" alt="Add a new test" /></li>
<li><strong> Open the class library in NUnit</strong><br />
Run up NUnit and click File | Open&#8230; and select your newly build class library DLL.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/06-open-project.gif" alt="Open class library" /></p>
<p>You can run the test if you like - it should pass.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/07-ready-to-test.gif" alt="Ready to run test" /></li>
<li><strong>Save the NUnit project</strong><br />
Now you need to save the NUnit project.  The NUnit project file is an XML file (surprise) that points to the assemblies that NUnit should load.</p>
<p>Click File Save As&#8230;, but don&#8217;t save it in the Debug folder. Rather go up a couple of levels and save it in the <em>project</em> folder. Call it ClassLibarary1.nunit. </p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/08-save-nunit-project.gif" alt="Save the NUnit project" /></li>
<li><strong> Setup NUnit as the class library&#8217;s startup process</strong><br />
Back in Visual Studio, select the ClassLibrary1 project in the Solution Explorer.<br />
Right-click and choose Properties.</p>
<p>Expand &#8220;Configuration Properties&#8221; and then select &#8220;Debugging&#8221;.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/09b-project-props.gif" alt="Project properties" /></p>
<p>Set &#8220;Debug Mode&#8221; to &#8220;Program&#8221;. Then click Apply.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/09c-project-props.gif" alt="Set Debug Mode" /></p>
<p>Set &#8220;Start Application&#8221; to the path to nunit-gui.exe. The default is &#8220;C:\Program Files\NUnit 2.2\bin\nunit-gui.exe&#8221;.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/09d-project-props.gif" alt="Set Start Application" /></p>
<p>Set the Command Line Arguments to the relative path to the NUnit project file (the ClassLibrary1.nunit file we saved in the previous step).<br />
This should be &#8220;..\..\ClassLibrary1.nunit&#8221; (the relative path from \ClassLibrary1\bin\Debug, to \ClassLibrary1).</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/09e-project-props.gif" alt="Set the Command Line Arguments" /></p>
<p>At this point, if you hit F5 to run the project, NUnit will launch, load ClassLibrary1.nunit, load the referenced assembly (ClassLibrary1.dll) and display all of the tests. Great!</p>
<p>If we set a breakpoint on the instantiation of Class1 in the CreateClass1 test and we run the test - lo and behold the debugger breaks on the breakpoint.</p>
<p><img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/16-debugger-breaks.gif " alt="Debugger hits the breakpoint" /></p>
<p>The power of this is not so much that you can debug your tests, but rather that you can easily debug any arbitrary part of your class library just by running the associated test. Joy!</p>
<p>But we are no there just yet. </p>
<p>If we were to check this into version control and someone else were to check it out, it would not work.
</li>
<li><strong>Making it version control friendly</strong><br />
The reason it will not work is that, by default, the Debugging Configuration Properties (where we told it to launch NUnit) are stored in a user-specific file. In our case, <em>ClassLibrary1.csproj.user</em>. There is no point checking this file into version control because, when someone else checks out the project and loads it up, Visual Studio will create a new <em>ClassLibrary1.csproj.user</em> file for them - by copying values from the project file. </p>
<p>So how do you check in the Debugging Configuration Properties?</p>
<p>When I looked at the two files (<em>ClassLibrary1.csproj</em> and <em>ClassLibrary1.csproj.user</em>) I saw that the both had the same schema (VisualStudioProject |  CSHARP | Build | Settings | Config). The relevant sections of the two files are as follows:</p>
<p><em>Debug config for ClassLibrary1.csproj.user</em><br />
<img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/22-user-file.gif " alt="Debug config for ClassLibrary1.csproj.user" /></p>
<p><em>Debug config for ClassLibrary1.csproj</em><br />
<img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/23-project-file.gif " alt="Debug config for ClassLibrary1.csproj" /></p>
<p>So, I tried copying the <em>Start</em>-related attributes from the user file to the project file and&#8230;miracles of miracles&#8230;it works a treat.</p>
<p><em>Debug config for ClassLibrary1.csproj after adding Start-related attributes</em><br />
<img src="http://www.makiwa.com/wp-content/files/VSNUnitTDD/24-merged.gif " alt="Debug config for ClassLibrary1.csproj after adding Start-related attributes" /></p>
</li>
</ol>
<p>So, there we have it. All requirements met: we can use NUnit as the test harness, the debug harness and other developers can check out the project and do the same.</p>
<p>Note: If developers have installed NUnit in different drives or folders they can use the user-specific project file to overrride the default setting. They only need to do this once, either through the Configuration Property editor, or by editing the user-specific project file directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.makiwa.com/index.php/2005/08/02/test-driving-class-libraries-with-nunit-and-visual-studio-2003/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
