<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">

  <title><![CDATA[andreas.schlapsi]]></title>
  
  <link href="http://www.andreas-schlapsi.com/" />
  <updated>2011-10-26T17:22:03+02:00</updated>
  <id>http://www.andreas-schlapsi.com/</id>
  <author>
    <name><![CDATA[Andreas Schlapsi]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/AndreasSchlapsi" /><feedburner:info uri="andreasschlapsi" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title type="html"><![CDATA[Second Python Coding Dojo in Vienna]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/wnz6MmYPhFU/" />
    <updated>2011-09-17T18:34:31+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2011/09/17/second-python-coding-dojo-in-vienna</id>
    <content type="html"><![CDATA[<p>On Wednesday, September 21, 2011, the next
<a href="http://www.pyug.at/PythonDojo">Python Coding Dojo</a> will take place
at the <a href="http://www.pyug.at/Treffen/2011-09">monthly meeting</a> of the
<a href="http://www.pyug.at">Python User Group Austria</a> in the
<a href="http://www.metalab.at">Metalab</a>. Python developers of all
experience levels and people interested in Python are welcome.</p>

<h2>What is a Coding Dojo?</h2>

<p>A coding dojo is a meeting, which brings together a number of
programmers to work on a programming challenge. It’s mainly about
solving the task in a relaxed atmosphere together and to learn new
things. A dojo is not a competition, but the focus is on the
learning. More information is available at
<a href="http://codingdojo.org">http://codingdojo.org</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2011/09/17/second-python-coding-dojo-in-vienna/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Python Coding Dojo in Vienna]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/XC9iVYWOvoI/" />
    <updated>2011-08-19T22:29:05+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2011/08/19/python-coding-dojo-in-vienna</id>
    <content type="html"><![CDATA[<p>On Sunday, August 21, 2011, a Python Coding Dojo takes place at the
August meeting of the <a href="http://pyug.at">Python User Group Austria</a>
in the <a href="http://www.metalab.at">Metalab</a>. We&#8217;ll probably use the
<a href="http://codingdojo.org/cgi-bin/wiki.pl?KataFizzBuzz">FizzBuzz kata</a>.
Python developers of all experience levels and people interested in
<a href="http://www.python.org">Python</a> are welcome.</p>

<h2>What is a Coding Dojo?</h2>

<p>A coding dojo is a meeting, which brings together a number of
programmers to work on a programming challenge. It&#8217;s mainly about
solving the task in a relaxed atmosphere together and to learn new
things. A dojo is not a competition, but the focus is on the
learning. More information is available on
<a href="http://codingdojo.org">http://codingdojo.org</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2011/08/19/python-coding-dojo-in-vienna/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[.NET TDD Roundup #1]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/d-oj9E8SIhs/" />
    <updated>2010-04-26T22:48:18+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2010/04/26/net-tdd-roundup-1</id>
    <content type="html"><![CDATA[<p>This is .NET TDD roundup #1. The .NET TDD roundup aggregates
information of interest to .NET developers using TDD/BDD. If you
have something interesting you have done or have run across, please
send me the URL with a brief description via the
<a href="http://www.andreas-schlapsi.com/contact/">contact link</a> on my
blog.</p>

<h2>Test-Driven Development</h2>

<ul>
<li><a href="http://www.methodsandtools.com/archive/archive.php?id=103">Writing Testable Code</a>

<ul>
<li>Isa Goksu writes about writing testable code.</li>
</ul>
</li>
<li><a href="http://agile.dzone.com/videos/moving-tdd-and-exploring">Moving to Test-Driven Development and Exploring Language Paradigms</a>

<ul>
<li>Eric Hagan interviews Michael Feathers.</li>
</ul>
</li>
<li><a href="http://blog.ezyang.com/2010/04/the-problem-with-xunit/">The Problem with xUnit</a>

<ul>
<li>Edward Z. Yang writes about why he believes that xUnit test
frameworks lead to more boilerplate code and how to use Haskell to
create DSL-like tests with
<a href="http://en.wikipedia.org/wiki/QuickCheck">QuickCheck</a>.</li>
</ul>
</li>
<li><a href="http://blog.objectmentor.com/articles/2010/03/30/some-rough-draft-tdd-demonstration-videos">Some Rough Draft TDD Demonstration Videos</a>

<ul>
<li>Brett Schuchert is doing a series of video on TDD. He already
published
<a href="http://blog.objectmentor.com/articles/2010/04/05/first-pass-completed-rough-draft-tdd-demonstration-videos">rough drafts of his videos</a>.</li>
</ul>
</li>
</ul>


<h2>Unit Test Frameworks</h2>

<h3>NUnit</h3>

<ul>
<li><a href="http://groups.google.com/group/nunit-discuss/browse_thread/thread/1d1953c34a2aaa05#">NUnit 2.5.5 released</a>

<ul>
<li>Charlie Poole released version 2.5.5 of <a href="http://nunit.org">NUnit</a>
last Friday. It can be downloaded from
<a href="http://nunit.org/index.php?p=download">here</a>.</li>
</ul>
</li>
<li><a href="http://www.nuclex.org/downloads/tools/39-nunit-template-for-asp-net-mvc-2">NUnit Template for ASP.NET MVC 2</a>

<ul>
<li>Markus Ewald ported the MSTest unit test templates for ASP.NET
MVC 2 to NUnit. It isn&#8217;t ready though: it doesn&#8217;t add a reference
to the ASP.NET project.
<a href="http://groups.google.com/group/nunit-discuss/browse_thread/thread/24d7e086ef784a72#">Details</a>
can be found on the
<a href="http://groups.google.com/group/nunit-discuss">NUnit-Discuss mailing list</a>.</li>
</ul>
</li>
</ul>


<h3>MbUnit</h3>

<ul>
<li><a href="http://interfacingreality.blogspot.com/2010/04/xml-assertions-in-mbunit-v3.html">XML Assertions in MbUnit v3</a>

<ul>
<li>Yann Trévin writes about new assertions in the upcoming MbUnit
3.2 which will help with testing XML output.</li>
</ul>
</li>
</ul>

]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2010/04/26/net-tdd-roundup-1/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[When Is a Test a Unit Test?]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/WL0Kg4I3Pp4/" />
    <updated>2009-09-20T21:54:03+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2009/09/20/when-is-a-test-a-unit-test</id>
    <content type="html"><![CDATA[<p>Developers write their tests usually with a unit test framework.
Often those tests are slow and unreadable. Almost always the tests
communicate with a database, a file system, a web service or other
external resources. Developers stop executing the tests regularly
and further they stop writing tests entirely, because &#8220;unit tests&#8221;
are so slow and hard to maintain.
<a href="http://www.michaelfeathers.com/" title="Homepage of Micheal Feathers">Michael Feathers</a>
has already summarized
<a href="http://www.artima.com/weblogs/viewpost.jsp?thread=126923" title="A Set of Unit Testing Rules">the criteria for unit tests in September 2005</a>:</p>

<blockquote><p>&#8220;A test is not a unit test if:</p>

<ul>
<li>It talks to the database</li>
<li>It communicates across the network</li>
<li>It touches the file system</li>
<li>It can&#8217;t run at the same time as any of your other unit tests</li>
<li>You have to do special things to your environment (such as
editing config files) to run it.</li>
</ul>


<p>Tests that do these things aren&#8217;t bad. Often they are worth
writing, and they can be written in a unit test harness. However,
it is important to be able to separate them from true unit tests so
that we can keep a set of tests that we can run fast whenever we
make our changes.&#8221;</p></blockquote>

<p>Developers often even do not write unit tests! They are writing
integration tests instead. Sometimes it takes more than knowing the
test attributes of the used unit test framework to write real unit
tests!</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2009/09/20/when-is-a-test-a-unit-test/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Windows Installer 4.5 SDK no longer available as stand-alone download]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/5Sq3y9JiwcY/" />
    <updated>2009-08-15T16:55:02+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2009/08/15/windows-installer-4-5-sdk-no-longer-available-as-stand-alone-download</id>
    <content type="html"><![CDATA[<p><a href="http://blogs.msdn.com/windows_installer_team/archive/2009/08/12/latest-sdk-for-windows-installer-5-0.aspx" title="Windows Installer Team Blog: Latest SDK for Windows Installer 5.0">Windows SDK for Windows 7 and .NET Framework 3.5 SP1 is now available to download</a>.
It includes the latest SDK for Windows Installer 5.0. Therefore the
stand-alone version of the Windows Installer 4.5 SDK is no longer
available for download.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2009/08/15/windows-installer-4-5-sdk-no-longer-available-as-stand-alone-download/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Resources for Setup Authors]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/PipYy2j-88o/" />
    <updated>2009-07-30T00:09:25+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2009/07/30/resources-for-setup-authors</id>
    <content type="html"><![CDATA[<p>In the last years I created Windows Installer packages (MSI files)
using various tools. Now I&#8217;m working on the installer for NUnit 3
and we&#8217;re using Windows Installer XML (WiX) version 3. I&#8217;m writing
this post to collect links to interesting resources for creating
setups using WiX.</p>

<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/cc185688(VS.85">Windows Installer SDK</a>.aspx)
in the MSDN library</li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=6A35AC14-2626-4846-BB51-DDCE49D6FFB6&amp;displaylang=en">Windows Installer 4.5 SDK</a>:
contains tools like Orca or the Windows Installer documentation as
CHM file.</li>
<li><a href="http://wix.sourceforge.net/">Windows Installer XML (WiX)</a>: a
toolset that builds Windows Installer packages from XML source
code.</li>
<li><a href="http://support.citrix.com/article/CTX415447">Understanding Microsoft Installer Logs</a></li>
<li><a href="http://releaseengineering.blogspot.com/2008/03/automated-install-testing-msi.html">Automated Install Testing - MSI Validation</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa368012(VS.85">Conditional Statement Syntax</a>.aspx)</li>
</ul>


<p>For getting started with WiX:</p>

<ul>
<li><a href="http://wix.sourceforge.net/manual-wix3/authoring_first_file.htm">Authoring your first .wxs file</a></li>
<li><a href="http://wix.sourceforge.net/manual-wix3/authoring_first_votive_project.htm">Creating a simple setup</a>
(using Votive)</li>
<li><a href="http://www.tramontana.co.hu/wix/">WiX Tutorial</a> (by Gábor DEÁK
JAHN)</li>
<li><a href="http://blogs.technet.com/alexshev/pages/from-msi-to-wix.aspx">From MSI to WiX</a>
(by Alex Shevchuk)</li>
<li><a href="http://installing.blogspot.com/2006/04/msi-validation-in-wix.html">MSI Validation in WiX</a>
(by Derek Cicerone)</li>
<li><a href="http://www.dizzymonkeydesign.com/blog/misc/adding-and-customizing-dlgs-in-wix-3/">Adding and Customizing Dialogs in WiX 3</a></li>
</ul>

]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2009/07/30/resources-for-setup-authors/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Creating NUnit projects]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/QimTEurbhio/" />
    <updated>2008-11-03T00:04:12+01:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/11/03/creating-nunit-projects</id>
    <content type="html"><![CDATA[<p>Since version 2.1, both the Console runner and the GUI runner of
NUnit can load tests from multiple test assemblies. The
<a href="http://www.nunit.com/index.php?p=documentation">NUnit documentation</a>
contains
<a href="http://www.nunit.com/index.php?p=multiAssembly&amp;r=2.4.8">more information about this feature</a>.
Still there can be one or more obstacles when you use multiple test
assemblies.</p>

<h3>Adhoc projects</h3>

<p>The Console runner accepts more than one test assemblies as command
line arguments. If you use the GUI runner you can add test
assemblies by using &#8220;Project => Add Assembly&#8230;&#8221;. But the test
assembly must be in the same directory as the assembly which has
already been loaded, otherwise NUnit can&#8217;t find the file and aborts
with a FileNotFoundException.</p>

<h3>Creating NUnit projects</h3>

<p>You can create a new NUnit test project by clicking on &#8220;File =>
New Project&#8230;&#8221;. You can add assemblies to the project by clicking
on &#8220;Project => Add Assembly&#8230;&#8221;. Using NUnit test projects the
test assemblies can be in different directories.</p>

<h3>One configuration file for all test assemblies</h3>

<p>NUnit can load configuration files for test assemblies even for
class libraries. With NUnit test projects you can use just one
configuration file. You can change the name of this file in the
NUnit project editor, but you can&#8217;t specify a file path, just the
file name. The configuration file must be located in the same
directory as the project file.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/11/03/creating-nunit-projects/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RenderAction and SubControllers in ASP.NET MVC]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/2iCzk-aOiEI/" />
    <updated>2008-11-01T16:02:16+01:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/11/01/renderaction-and-subcontrollers-in-aspnet-mvc</id>
    <content type="html"><![CDATA[<p>Last week I watched
<a href="http://www.asp.net/learn/mvc-videos/">some videos about ASP.NET MVC</a>.
Rob Conery creates
<a href="http://www.asp.net/learn/mvc-videos/video-364.aspx">in episode 11 of the &#8220;ASP.NET MVC Storefront&#8221; series</a>
an ASP.NET MVC Component. Using components you can call an action
method of a ComponentController and insert the rendered result into
the view. Mike Bosch explains this concept
<a href="http://weblogs.asp.net/mikebosch/archive/2008/03/10/using-the-componentcontroller-in-asp-net-mvc.aspx">in a blog post</a>.</p>

<p>In ASP.NET MVC Preview 4 ComponentController has been removed and
the method RenderComponent which called the ComponentController
action from the view has been replaced by the method RenderAction
which can call an action of a normal Controller. Since this concept
conflicts with
&#8221;<a href="http://en.wikipedia.org/wiki/Separation_of_Concerns">Separation of concerns</a>&#8221;,
Microsoft doesn&#8217;t intend to include this feature in the RTM version
of ASP.NET MVC.</p>

<h3>ASP.NET MVC Futures</h3>

<p>Therefore the ASP.NET MVC team moved the RenderAction method to the
ASP.NET MVC Futures which consist of the assembly
Microsoft.Web.Mvc.dll. This assembly contains features and
prototypes
<a href="http://haacked.com/archive/2008/07/16/aspnetmvc-codeplex-preview4.aspx">which haven&#8217;t been included in the RTM version yet</a>.
The release for ASP.NET MVC Beta 1 can be
<a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=18459">downloaded from Codeplex</a>.</p>

<p>In order to use ASP.NET MVC Futures in your MVC project reference
the assembly &#8220;Microsoft.Web.Mvc.dll&#8221; and insert the following line
into the web.config to include the namespace &#8220;Microsoft.Web.Mvc&#8221; in
all your views automatically:</p>

<p><img src="http://www.andreas-schlapsi.com/images/2008/11/renderaction_mvcfutures_webconfig.png" title="Configuration settings to include ASP.NET MVC futures in your views" alt="image" /></p>

<h3>SubControllers from MvcContrib</h3>

<p>SubControllers can be used for similar purposes like RenderAction
or Components. <a href="http://mhinze.com/">Matt Hinze</a> presented this
feature from the <a href="http://mvccontrib.org/">MvcContrib project</a>
<a href="http://mhinze.com/subcontrollers-in-aspnet-mvc/">in a blog post</a>.
SubController actions can be included in the view data as
delegates. The views can then invoke these delegates and start the
rendering of the SubController action view.</p>

<p>The host controller can pass objects to the SubController. Matt
Hinze explains this feature
<a href="http://mhinze.com/passing-objects-to-subcontrollers/">in another blog post</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/11/01/renderaction-and-subcontrollers-in-aspnet-mvc/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RowTest Extension 1.2.3]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/JDqzzRWpBa8/" />
    <updated>2008-09-30T00:38:17+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/09/30/rowtest-extension-123</id>
    <content type="html"><![CDATA[<p>I released a new version of the RowTest Extension. I made following
changes:</p>

<ul>
<li>The description of a Row attribute will be copied to the
created test case.</li>
</ul>


<p>You can download it from the
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">RowTest Extension page</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/09/30/rowtest-extension-123/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Detecting Testability Problems]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/2yOwdEM-Dhw/" />
    <updated>2008-07-07T22:05:53+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/07/07/detecting-testability-problems</id>
    <content type="html"><![CDATA[<p>Roy Osherove wrote a
<a href="http://weblogs.asp.net/rosherove/archive/2008/07/05/introducing-depender-testability-problem-finder.aspx">new tool, called Depender</a>.
It inspects the types within an assembly and tries to find possible
testability problems and places where you can already use seams to
inject your own implementation. If you&#8217;re not familiar with the
concept of seams you might want to read Michael Feather&#8217;s book
<a href="http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/0131177052/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1215459816&amp;sr=8-1">&#8220;Working Effectively with Legacy Code&#8221;</a>.
You can extend Depender by
<a href="http://weblogs.asp.net/rosherove/archive/2008/07/05/extending-depender-with-your-own-custom-dependency-rules.aspx">writing your own dependency rules</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/07/07/detecting-testability-problems/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[NUnit 2.4.7 includes RowTest Extension]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/S99LigxyhbE/" />
    <updated>2008-03-31T21:09:54+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/03/31/nunit-247-includes-rowtest-extension</id>
    <content type="html"><![CDATA[<p><a href="http://blogs.nunit.com/">Charlie Poole</a> released
<a href="http://nunit.org/index.php?p=home">NUnit</a> 2.4.7 today. This
release eliminates some problems related to NUnit&#8217;s interaction
with <a href="http://logging.apache.org/log4net/index.html">log4net</a> and
various bugs are also addressed.
<a href="http://nunit.org/index.php?p=releaseNotes&amp;amp;r=2.4.7">The release notes</a>
contain more detailed information.
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">RowTest Extension</a>
1.2.2 is packaged in the NUnit extension assemblies. It&#8217;s the first
time that an externally developed addin is included in a release of
NUnit. You&#8217;ll have to change the namespace from
<code>NUnitExtension.RowTest</code> to <code>NUnit.Framework.Extensions</code> if you
want to port your unit tests from older versions of RowTest
Extension. You can download NUnit 2.4.7 from the
<a href="http://nunit.org/index.php?p=download">NUnit site</a> or from
<a href="http://sourceforge.net/project/showfiles.php?group_id=10749&amp;amp;package_id=89482&amp;amp;release_id=588414">Sourceforge</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/03/31/nunit-247-includes-rowtest-extension/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RowTest Extension 1.2.2]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/4EtFaZ_xMzw/" />
    <updated>2008-03-30T19:32:09+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/03/30/rowtest-extension-122</id>
    <content type="html"><![CDATA[<p>I released a new version of the RowTest Extension. I made following
changes:</p>

<ul>
<li>null cannot be used as argument on .NET Framework 1.1. A new
enum value SpecialValue.Null can be used instead. If the RowTest
addin finds this value as argument the value will be translated to
null.</li>
<li>Fixed Bug: Common NUnit attributes like Category, Description
etc. don&#8217;t work for RowTest methods.</li>
</ul>


<p>You can download it from the
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">RowTest Extension page</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/03/30/rowtest-extension-122/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Using Bazaar and Launchpad on Windows]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/zOZ5zBpl2O4/" />
    <updated>2008-03-29T12:05:20+01:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/03/29/using-bazaar-and-launchpad-on-windows</id>
    <content type="html"><![CDATA[<p><a href="http://bazaar-vcs.org/">Bazaar</a> is a
<a href="http://en.wikipedia.org/wiki/Distributed_Version_Control_System">distributed version control system (DVCS)</a>
written in <a href="http://www.python.org/">Python</a> with many interesting
features. Like all DVCS it supports disconnected operation which
means that you don&#8217;t have to be connected to a central repository
to commit changes or to view the history.
<a href="https://launchpad.net/">Launchpad</a> is a free software hosting and
development site. Another well-known site of this category is
<a href="http://sourceforge.net/index.php">Sourceforge</a>. Launchpad was
originally created for <a href="http://www.ubuntu.com/">Ubuntu</a> and is now
used by many other open source projects, e.g.
<a href="http://www.zope.org/">Zope</a> and
<a href="http://www.infrae.com/products/silva">Silva CMS</a>. Erik Thomson
wrote some tips about
<a href="http://wiki.showmedo.com/index.php/Using_Launchpad_and_Bazaar">using Launchpad and Bazaar</a>
on Windows and made a
<a href="http://showmedo.com/videos/video?name=1510070&amp;amp;fromSeriesID=151">video tutorial</a>.
When I tried to make a first branch at Launchpad on Windows I had
some problems, though. I got errors like &#8220;bzr: ERROR: Don&#8217;t know
how to handle SSH connections. Please set BZR_SSH environment
variable.&#8221; or &#8220;bzr: ERROR: [Error 2] The system cannot find the
file specified&#8221;. To push changes from the local branch to Launchpad
Bazaar needs the python library
<a href="http://www.lag.net/paramiko/">paramiko</a> for SSH connections and it
were missing on my system. Paramiko requires
<a href="http://www.amk.ca/python/code/crypto.html">pycrypto</a>, binaries for
Windows can be found at
<a href="http://www.voidspace.org.uk/python/modules.shtml#pycrypto">The Voidspace Python Modules</a>.
To install paramiko install pycrypto first, extract the downloaded
zip package, change to the directory and call &#8220;&amp;path to
python&amp;\python setup.py install&#8221;. After installing the missing
libraries everything worked fine and you can find a branch for the
<a href="https://launchpad.net/nunit-rowtests/">RowTest extension for NUnit at Launchpad</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/03/29/using-bazaar-and-launchpad-on-windows/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RowTest Extension 1.2.1]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/44WjYvZ8iog/" />
    <updated>2008-02-17T20:42:34+01:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/02/17/rowtest-extension-121</id>
    <content type="html"><![CDATA[<p>I released a new version of the RowTest Extension. I made following
changes:</p>

<ul>
<li>Fixed Bug: SetUp and TearDown are not called on the RowTest
test suite</li>
<li>Created new Test project for functional tests and reorganized
samples.</li>
</ul>


<p>You can download it from the
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">RowTest Extension page</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/02/17/rowtest-extension-121/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RowTest Extension 1.2.0]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/KHAdcPuwsVE/" />
    <updated>2008-01-29T01:35:44+01:00</updated>
    <id>http://www.andreas-schlapsi.com/2008/01/29/rowtest-extension-120</id>
    <content type="html"><![CDATA[<p>I released a new version of the RowTest Extension. I made following
changes:</p>

<ul>
<li>Added build for .NET Framework 1.1.</li>
<li>Assemblies are now strongly named.</li>
<li>Added ExceptionMessage property to RowAttribute. It can be used
to specify the message of an expected exception.</li>
<li>Added TestName property to RowAttribute. It is used to provide
a custom name of the test. If TestName is null or empty the method
name will be used.</li>
<li>Fixed Bug: TestFixtureSetUp and TestFixtureTearDown are not
called on the RowTest test suite (thanks to
<a href="http://www.waynebrantley.com/">Wayne Brantley</a> for reporting the
bug and special thanks to Jamie Cansdale for providing a fix</li>
<li>Fixed Bug: When a TestFixture contains both RowTests and normal
unit tests the row tests are not alphabetically ordered.</li>
</ul>


<p>You can download it from
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">here</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2008/01/29/rowtest-extension-120/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[TestDriven.NET supports RowTestExtension]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/4K7hT_-Mvs0/" />
    <updated>2007-12-17T23:21:11+01:00</updated>
    <id>http://www.andreas-schlapsi.com/2007/12/17/testdrivennet-supports-rowtestextension</id>
    <content type="html"><![CDATA[<p><a href="http://weblogs.asp.net/nunitaddin/">Jamie Cansdale</a> published an
<a href="http://weblogs.asp.net/nunitaddin/archive/2007/12/17/testdriven-net-2-11-parameterized-nunit-tests.aspx">article on using parameterized tests with NUnit, TestDriven.NET and the RowTestExtension</a>
today. He released a new version of
<a href="http://www.testdriven.net/">TestDriven.NET</a> which improved the
support of NUnit AddIns.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2007/12/17/testdrivennet-supports-rowtestextension/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RowTestExtension 1.1.0 released]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/EglOffQEyfw/" />
    <updated>2007-10-27T16:36:01+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2007/10/27/rowtestextension-110-released</id>
    <content type="html"><![CDATA[<p>Yesterday I released the new version of the RowTestExtension, an
addin for <a href="http://www.nunit.com/index.php">NUnit</a>. I have made
following changes:</p>

<ul>
<li>Added ExpectedException property to the [Row] attribute. It can
be used to specify which type of exception to expect when the given
data is passed to the test.</li>
<li>The [Row] attribute accepts now null values.</li>
<li>Removed dependency from assembly NUnitExtension.RowTest.AddIn
to NUnitExtension.RowTest.</li>
</ul>


<p>You can download it from
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">here</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2007/10/27/rowtestextension-110-released/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Verifying Exceptions using IExpectException]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/y-U3BRbETZU/" />
    <updated>2007-08-21T14:26:58+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2007/08/21/verifying-exceptions-using-iexpectexception</id>
    <content type="html"><![CDATA[<p>The unit tests for <a href="http://www.nunit.com">NUnit</a> contain an
interesting pattern for verifying exception details. The abstract
class
<a href="http://nunit.cvs.sourceforge.net/nunit/nunit20/src/NUnitFramework/tests/MessageChecker.cs?revision=1.3&amp;view=markup"><code>MessageChecker</code></a>
in assembly nunit.framework.tests implements
<a href="http://www.nunit.com/index.php?p=exception&amp;r=2.4.3"><code>IExpectException</code></a>,
an interface introduced with NUnit 2.4. Test cases in derived test
fixtures set the protected field <code>expectedMessage</code> to the expected
exception message which can span several lines or include data from
the test setup. Here is another example:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">FileNotFoundExceptionChecker</span> <span class="p">:</span> <span class="n">IExpectException</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>    <span class="k">private</span> <span class="kt">string</span> <span class="n">_expectedFileName</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">public</span> <span class="nf">FileNotFoundExceptionChecker</span><span class="p">()</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">public</span> <span class="k">void</span> <span class="nf">HandleException</span><span class="p">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="p">)</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>        <span class="k">if</span> <span class="p">(</span><span class="n">_expectedFileName</span> <span class="p">==</span> <span class="k">null</span><span class="p">)</span>
</span><span class='line'>            <span class="k">return</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>        <span class="n">Assert</span><span class="p">.</span><span class="n">IsInstanceOfType</span> <span class="p">(</span><span class="k">typeof</span> <span class="p">(</span><span class="n">FileNotFoundException</span><span class="p">),</span> <span class="n">ex</span><span class="p">);</span>
</span><span class='line'>        <span class="n">FileNotFoundException</span> <span class="n">fileNotFoundException</span> <span class="p">=</span> <span class="p">(</span><span class="n">FileNotFoundException</span><span class="p">)</span> <span class="n">ex</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>        <span class="n">StringAssert</span><span class="p">.</span><span class="n">Contains</span><span class="p">(</span><span class="n">_expectedFileName</span><span class="p">,</span> <span class="n">fileNotFoundException</span><span class="p">.</span><span class="n">Message</span><span class="p">);</span>
</span><span class='line'>        <span class="n">Assert</span><span class="p">.</span><span class="n">AreEqual</span><span class="p">(</span><span class="n">_expectedFileName</span><span class="p">,</span> <span class="n">fileNotFoundException</span><span class="p">.</span><span class="n">FileName</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">protected</span> <span class="k">void</span> <span class="nf">ExpectMissingFile</span><span class="p">(</span><span class="kt">string</span> <span class="n">fileName</span><span class="p">)</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>        <span class="n">_expectedFileName</span> <span class="p">=</span> <span class="n">fileName</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="na">[TestFixture]</span>
</span><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">FileTest</span> <span class="p">:</span> <span class="n">FileNotFoundExceptionChecker</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'><span class="na">    [Test]</span>
</span><span class='line'><span class="na">    [ExpectedException(typeof(FileNotFoundException))]</span>
</span><span class='line'>    <span class="k">public</span> <span class="k">void</span> <span class="nf">ReadAllBytes</span><span class="p">()</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>        <span class="kt">string</span> <span class="n">fileName</span> <span class="p">=</span> <span class="s">@&quot;C:\notexistingfile.txt&quot;</span><span class="p">;</span>
</span><span class='line'>        <span class="n">ExpectMissingFile</span><span class="p">(</span><span class="n">fileName</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>        <span class="n">File</span><span class="p">.</span><span class="n">ReadAllBytes</span><span class="p">(</span><span class="n">fileName</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2007/08/21/verifying-exceptions-using-iexpectexception/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[RowTests with NUnit 2.4]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/GtjE5sqb1zw/" />
    <updated>2007-08-17T14:34:55+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2007/08/17/rowtests-with-nunit-24</id>
    <content type="html"><![CDATA[<p>I had some time last week and therefore I played around with the
new extensibility features of
<a href="http://nunit.com/index.php">NUnit 2.4</a>. I wanted to know, how
difficult it is to implement the
<a href="http://haacked.com/archive/2004/10/20/row_based_testing.aspx">RowTest feature</a>
of <a href="http://www.mbunit.com/">MbUnit</a> as
<a href="http://www.andreas-schlapsi.com/2007/05/11/how-to-build-an-nunit-addin/">NUnit Addin</a>.
Two hours later the
<a href="http://www.andreas-schlapsi.com/projects/rowtest-extension-for-nunit/">RowTest Extension for NUnit</a>
was ready. I released the extension under the
<a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.
The following code snippet shows you how to use the extension:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="na">[TestFixture]</span>
</span><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">RowTestSample</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'><span class="na">     [RowTest]</span>
</span><span class='line'><span class="na">     [Row( 1000, 10, 100.0000)]</span>
</span><span class='line'><span class="na">     [Row(-1000, 10, -100.0000)]</span>
</span><span class='line'><span class="na">     [Row( 1000, 7, 142.85715)]</span>
</span><span class='line'><span class="na">     [Row( 1000, 0.00001, 100000000)]</span>
</span><span class='line'><span class="na">     [Row(4195835, 3145729, 1.3338196)]</span>
</span><span class='line'>     <span class="k">public</span> <span class="k">void</span> <span class="nf">DivisionTest</span><span class="p">(</span><span class="kt">double</span> <span class="n">num</span><span class="p">,</span> <span class="kt">double</span> <span class="n">den</span><span class="p">,</span> <span class="kt">double</span> <span class="n">res</span><span class="p">)</span>
</span><span class='line'>     <span class="p">{</span>
</span><span class='line'>        <span class="n">Assert</span><span class="p">.</span><span class="n">AreEqual</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="n">num</span> <span class="p">/</span> <span class="n">den</span><span class="p">,</span> <span class="m">0.00001</span><span class="p">);</span>
</span><span class='line'>     <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>The current release does not support all features of MbUnit
RowTests, e.g. Exceptions cannot be tested.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2007/08/17/rowtests-with-nunit-24/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Decorate Your Tests]]></title>
    <link href="http://feedproxy.google.com/~r/AndreasSchlapsi/~3/oXpng9gL-zQ/" />
    <updated>2007-06-07T17:37:15+02:00</updated>
    <id>http://www.andreas-schlapsi.com/2007/06/07/decorate-your-tests</id>
    <content type="html"><![CDATA[<p>In
<a href="http://www.andreas-schlapsi.com/2007/05/11/how-to-build-an-nunit-addin/">my last post</a>
I showed you how to write a minimal NUnit addin. It didn&#8217;t do
anything useful, so let&#8217;s see what we can do with test decorators.</p>

<h3>What Is a Test Decorator?</h3>

<p>The <a href="http://c2.com/cgi/wiki?DecoratorPattern">Decorator Pattern</a>
describes a design for attaching additional responsibilities to an
object dynamically. It is also known as Wrapper. Test Decorators
wrap a single test case or a test fixture and therefore allow you
to run some code before and after it.</p>

<p>Typical uses for test decorators are measuring performance or
setting up and cleaning up a database.</p>

<h3>Copy a File Before Running a Test</h3>

<p>(You can find the
<a href="http://www.andreas-schlapsi.com/downloads/copyfiletestextension.zip" title="CopyFile NUnit Addin">source for the examples here</a>.)</p>

<p>Assume that a test needs a certain file each time you run a test.
If those tests are in the same test fixture and there are no other
tests in this fixture, you will use a setup method. Otherwise test
decorators may help you. Furthermore test decorators provide a way
to share test extensions.</p>

<p>So, let&#8217;s start by writing an NUnit addin:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="na">[NUnitAddin(Name=&quot;Copy File Decorator Addin&quot;,</span>
</span><span class='line'><span class="na">            Description=&quot;Copies a file before running the test.&quot;)]</span>
</span><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">CopyFileAddin</span> <span class="p">:</span> <span class="n">IAddin</span><span class="p">,</span> <span class="n">ITestDecorator</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="k">public</span> <span class="kt">bool</span> <span class="nf">Install</span><span class="p">(</span><span class="n">IExtensionHost</span> <span class="n">host</span><span class="p">)</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>    <span class="n">IExtensionPoint</span> <span class="n">decorators</span> <span class="p">=</span> <span class="n">host</span><span class="p">.</span><span class="n">GetExtensionPoint</span><span class="p">(</span><span class="s">&quot;TestDecorators&quot;</span><span class="p">);</span>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="n">decorators</span> <span class="p">==</span> <span class="k">null</span><span class="p">)</span>
</span><span class='line'>      <span class="k">return</span> <span class="k">false</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">decorators</span><span class="p">.</span><span class="n">Install</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
</span><span class='line'>    <span class="k">return</span> <span class="k">true</span><span class="p">;</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>As <code>CopyFileAddin</code> implements both the <code>IAddin</code> and the
<code>ITestDecorator</code> interfaces, it installs itself at the extension
point &#8220;TestDecorators&#8221;. I described the <code>IAddin</code> interface in
<a href="http://www.andreas-schlapsi.com/2007/05/11/how-to-build-an-nunit-addin/">my last post</a>
and <code>ITestDecorator</code> declares the method Decorate and
<code>CopyFileAddin</code> implements it as follows:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="n">Test</span> <span class="nf">Decorate</span><span class="p">(</span><span class="n">Test</span> <span class="n">test</span><span class="p">,</span> <span class="n">MemberInfo</span> <span class="n">member</span><span class="p">)</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="c1">// Decorate only single test cases</span>
</span><span class='line'>  <span class="k">if</span> <span class="p">(</span><span class="n">test</span> <span class="k">is</span> <span class="n">TestCase</span><span class="p">)</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>    <span class="n">Attribute</span> <span class="n">attribute</span> <span class="p">=</span> <span class="n">Reflect</span><span class="p">.</span><span class="n">GetAttribute</span><span class="p">(</span>
</span><span class='line'>        <span class="n">member</span><span class="p">,</span> <span class="s">&quot;CopyFileTest.Framework.CopyFileAttribute&quot;</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="n">attribute</span> <span class="p">!=</span> <span class="k">null</span><span class="p">)</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>      <span class="kt">string</span> <span class="n">sourcePath</span> <span class="p">=</span> <span class="p">(</span><span class="kt">string</span><span class="p">)</span><span class="n">Reflect</span><span class="p">.</span><span class="n">GetPropertyValue</span><span class="p">(</span><span class="n">attribute</span><span class="p">,</span>
</span><span class='line'>          <span class="s">&quot;SourcePath&quot;</span><span class="p">,</span> <span class="n">BindingFlags</span><span class="p">.</span><span class="n">Public</span> <span class="p">|</span> <span class="n">BindingFlags</span><span class="p">.</span><span class="n">Instance</span><span class="p">);</span>
</span><span class='line'>      <span class="kt">string</span> <span class="n">destinationPath</span> <span class="p">=</span> <span class="p">(</span><span class="kt">string</span><span class="p">)</span><span class="n">Reflect</span><span class="p">.</span><span class="n">GetPropertyValue</span><span class="p">(</span><span class="n">attribute</span><span class="p">,</span>
</span><span class='line'>          <span class="s">&quot;DestinationPath&quot;</span><span class="p">,</span> <span class="n">BindingFlags</span><span class="p">.</span><span class="n">Public</span> <span class="p">|</span> <span class="n">BindingFlags</span><span class="p">.</span><span class="n">Instance</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>      <span class="n">test</span> <span class="p">=</span> <span class="k">new</span> <span class="n">CopyFileTestCase</span><span class="p">((</span><span class="n">TestCase</span><span class="p">)</span> <span class="n">test</span><span class="p">,</span>
</span><span class='line'>          <span class="n">sourcePath</span><span class="p">,</span> <span class="n">destinationPath</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">return</span> <span class="n">test</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>In NUnit 2.4 you mark tests to be wrapped by using specific .NET
attributes. The test decorator extension identifies those tests and
wrap them with a special decorator test case class, e.g. the
following test case will be wrapped with a <code>CopyFileTestCase</code> if
the <code>CopyFileAddin</code> is properly installed in your NUnit – in
<a href="http://www.andreas-schlapsi.com/2007/05/11/how-to-build-an-nunit-addin/">my last post</a>
I described how to do this.</p>

<p>The attribute <code>CopyFile</code> marks the test case to be wrapped and
stores the source and destination path of the file to be copied.
The test may be run in another thread, so the paths must be
absolute.</p>

<p>The decorator class looks like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">public</span> <span class="k">class</span> <span class="nc">CopyFileTestCase</span> <span class="p">:</span> <span class="n">TestCase</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="k">private</span> <span class="n">TestCase</span> <span class="n">_testCase</span><span class="p">;</span>
</span><span class='line'>  <span class="k">private</span> <span class="kt">string</span> <span class="n">_sourceFilePath</span><span class="p">;</span>
</span><span class='line'>  <span class="k">private</span> <span class="kt">string</span> <span class="n">_destinationPath</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">public</span> <span class="nf">CopyFileTestCase</span><span class="p">(</span>
</span><span class='line'>      <span class="n">TestCase</span> <span class="n">testCase</span><span class="p">,</span>
</span><span class='line'>      <span class="kt">string</span> <span class="n">sourceFilePath</span><span class="p">,</span>
</span><span class='line'>      <span class="kt">string</span> <span class="n">destinationPath</span><span class="p">)</span>
</span><span class='line'>      <span class="p">:</span> <span class="k">base</span><span class="p">((</span><span class="n">TestName</span><span class="p">)</span><span class="n">testCase</span><span class="p">.</span><span class="n">TestName</span><span class="p">.</span><span class="n">Clone</span><span class="p">())</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>    <span class="n">_testCase</span> <span class="p">=</span> <span class="n">testCase</span><span class="p">;</span>
</span><span class='line'>    <span class="n">_sourceFilePath</span> <span class="p">=</span> <span class="n">sourceFilePath</span><span class="p">;</span>
</span><span class='line'>    <span class="n">_destinationPath</span> <span class="p">=</span> <span class="n">destinationPath</span><span class="p">;</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">public</span> <span class="k">override</span> <span class="k">void</span> <span class="nf">Run</span><span class="p">(</span><span class="n">TestCaseResult</span> <span class="n">result</span><span class="p">)</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="n">File</span><span class="p">.</span><span class="n">Exists</span><span class="p">(</span><span class="n">_sourceFilePath</span><span class="p">))</span>
</span><span class='line'>      <span class="n">File</span><span class="p">.</span><span class="n">Copy</span> <span class="p">(</span><span class="n">_sourceFilePath</span><span class="p">,</span> <span class="n">_destinationPath</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">_testCase</span><span class="p">.</span><span class="n">Run</span><span class="p">(</span><span class="n">result</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="n">File</span><span class="p">.</span><span class="n">Exists</span><span class="p">(</span><span class="n">_destinationPath</span><span class="p">))</span>
</span><span class='line'>      <span class="n">File</span><span class="p">.</span><span class="n">Delete</span><span class="p">(</span><span class="n">_destinationPath</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<h3>Test Cases And Test Suites</h3>

<p>Maybe you are wondering, what the classes <code>Test</code> and <code>TestCase</code> are
about. NUnit organizes tests in test cases and test suites and both
are tests. They form another design pattern known as
<a href="http://c2.com/cgi/wiki?CompositePattern">Composite</a>.</p>

<p><img src="http://www.andreas-schlapsi.com/images/2007/06/nunit-test-class-hierarchy.png" alt="Test, TestCase and TestSuite" /></p>

<p>If your decorator supports single test cases only it will wrap a
<code>TestCase</code>, like <code>CopyFileTestCase</code>. You may decorate test suites
or both test cases and test suites by wrapping a <code>TestSuite</code> or
<code>Test</code> object respectively.</p>

<h3>RepeatedTestDecorator and MaxTimeDecorator</h3>

<p>NUnit 2.4 already provides a test decorator: the
<code>RepeatedTestDecorator</code>. You can find it in the assembly
&#8220;nunit.framework.extensions.dll&#8221;.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="k">using</span> <span class="nn">System</span><span class="p">;</span>
</span><span class='line'><span class="k">using</span> <span class="nn">NUnit.Framework</span><span class="p">;</span>
</span><span class='line'><span class="k">using</span> <span class="nn">NUnit.Framework.Extensions</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">namespace</span> <span class="nn">RepeatedTest</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'><span class="na">  [TestFixture]</span>
</span><span class='line'>  <span class="k">public</span> <span class="k">class</span> <span class="nc">RepeatedTestFixture</span>
</span><span class='line'>  <span class="p">{</span>
</span><span class='line'>    <span class="k">private</span> <span class="kt">int</span> <span class="n">_count</span><span class="p">;</span>
</span><span class='line'><span class="na">        </span>
</span><span class='line'><span class="na">    [TestFixtureSetUp]</span>
</span><span class='line'>    <span class="k">public</span> <span class="k">void</span> <span class="nf">TestFixtureSetUp</span><span class="p">()</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>      <span class="n">_count</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'><span class="na">        </span>
</span><span class='line'><span class="na">    [Test]</span>
</span><span class='line'><span class="na">    [Repeat(5)]</span>
</span><span class='line'>    <span class="k">public</span> <span class="k">void</span> <span class="nf">RepeatedTestCase</span><span class="p">()</span>
</span><span class='line'>    <span class="p">{</span>
</span><span class='line'>      <span class="n">_count</span><span class="p">++;</span>
</span><span class='line'>      <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">_count</span><span class="p">);</span>
</span><span class='line'>      <span class="k">if</span> <span class="p">(</span><span class="n">_count</span> <span class="p">==</span> <span class="m">5</span><span class="p">)</span>
</span><span class='line'>        <span class="n">Assert</span><span class="p">.</span><span class="n">Fail</span><span class="p">(</span><span class="s">&quot;The test has been repeated 5 times.&quot;</span><span class="p">);</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>You will have to reference the assembly
&#8220;nunit.framework.extensions.dll&#8221;. The test will fail with the
provided message. The NUnit package installs some sample projects
and amongst them a solution with examples for the new Core
Extensibility features. There you can find the sample decorator
<code>MaxTimeDecorator</code>, which fails a test when its duration exceeds a
provided limit.</p>

<h3>Downsides</h3>

<p>Currently there is no way to specify an Addin as requirement.
Imagine, you&#8217;ve written a unit test using the <code>MaxTimeDecorator</code>.
Your test will fail if it runs longer than the provided limit. You
commit your changes to your source repository. Your colleague gets
the new unit test from the repository and works on the program. Her
changes affect the performance of the code and the test lasts
longer than required. If she didn&#8217;t install the <code>MaxTimeDecorator</code>
Addin, she would not notice the defect.</p>

<p>There is currently no mechanism to control the order in which the
decorators are applied. NUnit applies decorators in the order in
which they are returned through reflection. Therefore pay attention
to this issue if you use more than one decorator.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='csharp'><span class='line'><span class="na">[Test]</span>
</span><span class='line'><span class="na">[Repeat(5)]</span>
</span><span class='line'><span class="na">[MaxTime(1100)]</span>
</span><span class='line'><span class="k">public</span> <span class="k">void</span> <span class="nf">RepeatedTestCase</span><span class="p">()</span>
</span><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="n">_count</span><span class="p">++;</span>
</span><span class='line'>  <span class="n">System</span><span class="p">.</span><span class="n">Threading</span><span class="p">.</span><span class="n">Thread</span><span class="p">.</span><span class="n">Sleep</span><span class="p">(</span><span class="m">1000</span><span class="p">);</span>
</span><span class='line'>  <span class="k">if</span> <span class="p">(</span><span class="n">_count</span> <span class="p">==</span> <span class="m">5</span><span class="p">)</span>
</span><span class='line'>    <span class="n">Assert</span><span class="p">.</span><span class="n">Fail</span><span class="p">(</span><span class="s">&quot;The test has been repeated 5 times.&quot;</span><span class="p">);</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>In this example it is not predictable if the test will fail because
of the counter or the exceeded time limit. If the <code>RepeatDecorator</code>
wraps the <code>MaxTimeDecorator</code>, it will fail because of the counter,
otherwise because of the time limit.</p>

<h3>More Information</h3>

<p>If you need more information about NUnit addins, have a look at the
<a href="http://www.nunit.com/index.php?p=nunitAddins&amp;r=2.4.1">NUnit documentation</a>.</p>
]]></content>
  <feedburner:origLink>http://www.andreas-schlapsi.com/2007/06/07/decorate-your-tests/</feedburner:origLink></entry>
  
</feed>

