in

ASP.NET Weblogs

Extreme JS

JS Greenwood's WebLog on architecture, .NET, processes, and life...

NUnit MSI - an NUnit plugin for Setup & Deploy packages

One of the things that's irked me for quite some time is how, even in a mature TDD environment, the tests that are written never seem to make it past the integration server.  Yet vast amounts of time gets spent tracing and fixing the differences between environments that cause glitches in execution.  The time it takes to spot these errors and the fact that the installation of bad software has already occured makes it a bit like shutting the stable door after the horse has bolted.  To me, it became apparent quite some time ago that tests shouldn't just be a means of validating refactorings and amends locally, they should also be a first line of defence when it comes to deploying to and troubleshooting environments (security factors aside).

So, after a few late nights over the last week, the project I've been working on has been finished - NUnit MSI.  This application does pretty much what it says on the tin - it sits in MSI installers as a custom action and runs the tests as part of the installation package, deciding whether or not to continue installation based upon success (and the user's input if so desired).  It can be downloaded from: http://www.altervisitor.com/software/NUnitMSI.msi, and here's a screenshot to give you an idea:


Screenshot of NUnit MSI

As well as running from within installers, I personally now use it as a custom build action to give me a "green light" that I've not broken anything, rather than having the heavier-weight NUnit GUI running all the time (although it is still useful for persistent errors and larger projects).

The code for NUnit MSI is based directly on NUnit v2.2 (2.2.0), and makes use of all the behind the scenes logic from that, just re-implementing the UI portion of NUnit. Full instructions are included in the archive, and are summarised (in brief) below.  As a parting comment, if you use this, please let me know give me feedback - I'm all for extending it, polishing it, making it work as a VS.NET plugin, etc.

  Running the NUnitMSI.exe application without any command line
  parameters will look in the folder it resides in for the first file with a
  .nunit file extension.  This will automatically be loaded and the tests run.
  If all the tests succeed, the application will pause for one second then
  exit successfully.  This is the exact same behaviour if it is added to a
  Setup and Deploy project.
 
  More advanced command-line usage takes the form:
  NUnitMSI.exe [config.nunit] [/queryerrors]
 
  Giving a relative filepath for "config.nunt" will cause the specified NUnit
  project file to be loaded, instead of one being probed for.
  The "/queryerrors" parameter will cause a dialog to be shown should errors
  be detected, asking the user if they wish to continue with installation
  regardless.  The default is to NOT show this dialog, and for a failed test
  to result in the installation rolling back.  However, whenever tests fail,
  whether this dialog is shown or not, the GUI does NOT automatically exit -
  it remains open to allow the user to inspect the errors in more detail.
 
  Usage example:  "NUnitMSI.exe ../tests.nunit /queryerrors"
 
  This basic-usage mode allows for NUnit MSI to be integrated with a local
  build process as a "post build action", allowing for a succinct graphical
  display of the test results, rather than requiring a heavyweight interface
  such as the NUnit GUI, or having to parse the output of the command line
  installer.
 
  NOTE: once the tests have completed, pressing "F10" on the form will cause
  them to run again.  This is not documented in the GUI, but is useful when
  running the application as an alternative to the standard NUnit GUI
  interface;.
 
  NOTE: If the application does not have a ".nunit" file specified, and it
  cannot locate one in the execution directory, it will exit automatically
  with a status code of "-3".  Other status codes are:
    0: OK
    -1: Tests failed
    -2: Invalid ".nunit" file specified

Published Aug 18 2004, 02:26 AM by jsgreenwood
Filed under: ,

Comments

 

AndrewSeven said:

A step forward.
August 17, 2004 9:49 PM
 

TrackBack said:

August 18, 2004 2:42 PM
 

TrackBack said:

August 18, 2004 3:02 PM
 

Graham said:

Any chance we can get the source for this as well?
August 18, 2004 7:19 PM
 

JS Greenwood said:

> Any chance we can get the source for this as well?

Absolutely, if anyone really wants the source, feel free to mail me and ask for it. Bear in mind that it IS just a new GUI for NUnit though - there's nothing clever there really.

To demonstrate that, here's the development process, which has only taken me some time out of my evenings since Saturday night or so:
1. Take the NUnit GUI VS.NET project, and combine it with the NUnit UI Kit project, into one EXE (and rename the project)
2. Tear out all of the extraneous controls, moving the object-model for the tests from behind the left-hand tree into the main applicationetc.
3. Add a listbox that's tied to the OnTestComplete (or similar) event, and other UI spit & polish
4. Amend command line parameters, and make it test automatically on start-up
5. Write a quick ProjectInstaller class.

My only reservation with making the source available is that I'd like to get the NUnit team to add more to the main distribution (such as this and the updated main GUI), rather than having uncoordinated offshoot projects similar to this one.

But, again, the source is available to anyone that wants it... If you could drop the NUnit team an e-mail at the same time asking them to integrate this stuff into thir releases, that'd be great, too... :)
August 18, 2004 7:27 PM
 

Graham said:

Wasn't really planning on making additions right now, I just like looking at code when I get the chance ;)

Feel free to email it over, we might start integrating this into our nightly builds with nunit.
August 18, 2004 9:27 PM
 

TrackBack said:

August 19, 2004 4:09 AM
 

Craig Neuwirt said:

How can I get this to work with the latests CVS snapshot of NUnit. I build NUnit from scratch so I was wondering if you could mail me the NUnit MSI source so I can build it with my version of NUnit.

thanks,
craig
August 20, 2004 8:42 AM
 

JS Greenwood said:

The source just references the nunit.framework.dll, nunit.core.dll, etc. assemblies, and the MSI file includes v2.2.0 of the DLLs it requires, so you can use your latest NUnit build for "normal" testing, and this for Setup & Deploy packages.

Craig, I'll mail you with the source - it just has references to the nunit.framework.dll, nunit.core.dll bnaries, etc. So you should be able to rebuild it against ongoing changes.

As a comment to everyone: I'm only going to support this with each "proper release" of NUnit - if there are bugs with in-development NUnit code, I'll sympathise, but that's probably about it. :)
August 20, 2004 8:51 AM
 

file is not displayed said:

when i acesses the - http://www.altervisitor.com/software/NUnitMSI.msi , the browser is displaying the page with Junk characters. Are there any other alternative links to download.

I am using IE 6.0

Thanks very much
Vijay
August 23, 2004 12:27 PM
 

JS Greenwood said:

"http://www.altervisitor.com/software/NUnitMSI.msi" is a virtual URL that redirects to:
http://homepage.ntlworld.com/james.greenwood4/software/NUnitMSI.msi

I can't guarantee that it'll remain on that specific "real" URL for ever. But, for now, that's a direct link to it. If anyone has any decent hosting capability that they'd like to share with me, I'll happily host the files elsewhere. :)
August 23, 2004 2:04 PM
 

TrackBack said:

October 6, 2004 10:24 AM
 

TrackBack said:

October 6, 2004 10:29 AM
 

TrackBack said:

October 6, 2004 7:38 PM
 

TrackBack said:

October 6, 2004 7:38 PM
 

TrackBack said:

October 8, 2004 12:52 PM
 

Arshath Ahmed said:

Hi,

Currently we are using Install Shield 12 for packaging the deployment setup. We wanted to perform a unit test to make sure everything is as required in the packaged (.msi) file.

We found the NUnit MSI would be the right tool in this scenario.

In this article, we can find how we could call the command line code to run the unit test for MSI.

Can we get some sample code or tutorial (URL) for the same? It would be a great help.

Thanks in advance.

May 24, 2007 5:49 AM
 

arshathl said:

How do we build the config.nunit file (format), which is passed as a parameter to NUnitMSI.exe?

May 24, 2007 6:08 AM
 

Aaron Driesbach said:

Wow thanks for the great tool!  I just found another really good one using Google to create NUnit Tests.  

www.kellermansoftware.com/p-30-nunit-test-generator.aspx

September 27, 2007 8:08 AM

Leave a Comment

(required)  
(optional)
(required)  
Add