Last.FM: Recently listened

Sunday, November 27, 2005

[.NET] Setting up nUnit

As I am somehow addicted to information technology, I'd rather have this blog being a technical one with some soccer-related posts than the other way round. Therefore I am going to start a series about my experiences with unit testing in Microsoft's .NET framework.

This is not going to be a full-flavored introduction to unit testing and agile (extreme) software development at all. For complete information on these topics, Wikipedia's article about unit testing and the eXtreme Programming Homepage are good starting points which I'd like to point you to.

Besides programming mostly in C during my studies (which in fact is a great language!), my favorite programming languages for hobby projects are Python and C#. For a hobby project which is in its early steps at the moment (and which I will link at most if there is something to view on its SourceForge homepage), I am searching for a unit testing environment for .NET languages.

With google as one of your best friends you will soon stumble upon nUnit - the .NET version of the xUnit unit testing framework. Unfortunately it was not able to cope with the newest beta releases of the .NET framework 2.0. I spent a lot of time trying to compile the sources which are available from the project's website, but it really did not make me happy.

Lucky me, today I found out, that they have released nUnit version 2.2.3 which is finally able to run with the latest .NET versions. Therefore setting up nUnit is now quite easy - download the 2.2.3 msi from the nUnit homepage and run the installer. Worked pretty fine for me.

There are express editions of the new Visual Studio languages available and they are free for download until November 2006. Unlike the full-fledged VS2005, these editions however do not contain any unit testing support. This is bad. Even worse: Unlike the real VS, the express editions can not be extended by plugins. An nUnit addin is available for the studio and would have been a great help in developing with Visual C# Express and nUnit.

So the next step to do is setting up nUnit and Visual C# Express another way. Assume you have a production project opened in VC# Express and you want to add unit testing to this project.
  1. Add a new project to your solution. This should be a dynamically linked library and will contain our test functions.
  2. In the solution explorer right-click the DLL's references and chose "add reference".
  3. From the dialog opening, chose "nUnit.Framework" from the ".NET" tab and the project you want to test from the "Projects" tab.
  4. The real Visual studio seems to enable users to add a startup action to a project so that you can run nUnit every time you hit F5 / Run. Visual C# Express will not let me run a DLL project so I chose to add a post-build event for my test library.
    To do so, right-click the project and chose "Properties". In the "Build events" tab add a post-build event
    C:\Programme\Nunit\bin\nunit-gui.exe $(TargetFileName) /run
    (where C:\Programme\Nunit is the directory you installed nUnit to) and check that the post-build event is run whenever the build process succeeds.
    This postbuild event will run nUnit every time you rebuild your test library (e.g., by calling "Build solution") and tell nUnit's graphical console to run the tests in your test library.
  5. Now that we are done, it is possible to run nUnit from VC# Express by hitting one key.

One thing I noticed regarding post-build events: When nUnit is installed in a directory whose name contains whitespaces, place the directory name into quotation marks, otherwise the postbuild event will fail with an error code 9009 (which probably means "file not found").

2 comments:

Bjoern said...

Probably you want to click on the "nUnit addin" link in the post above and download and install the addin. I hope there is already a VS2005 version available.

stories incest young said...

But Stephanie hated him she had spurned him time andtime again, making him even more desperate to haveher. .
bestiality dog sex stories free
erotic sibling incest sex stories
stories lesbian
free stories sex post
adult stories
But Stephanie hated him she had spurned him time andtime again, making him even more desperate to haveher. .