views:

29

answers:

2

Hello Everyone,

I am working on a C# WinForms application in VC# 2008 Express, writing unit tests with NUnit 2.5.5, and running them via the NUnit GUI program. Right now to run them I switch the output type to 'class library' and then switch back to 'windows application' after I'm done testing. I just have NUnit reading from the bin/Release directory, which is erased when I rebuild. I would like to be able to compile both the class library and executable with a single action so I can test via NUnit and still run as a windows application.

I was thinking to use the post-build events in VC# but have never used them (I'm new to NUnit as well), is there a way to accomplish this? Should I be doing this a different way? Any suggestions are appreciated!

A: 

Hi,

Why not build your NUnit tests as a separate project within the solution? Simply add the main application as a dependency to the NUnit test project.

If you then set the NUnit module to build as a library, and the main application to build as an executable, you should achieve the desired effect.

Martin Eve
Thank you for the response. I have the tests as a project as you said, however the dll that the test ends up referencing is an old version from when I compiled as a class library; when I make changes to the main app it is compiled as an exe, but the dll I see the test project reference has not changed.
+1  A: 

It is a .NET goodie: the public classes in a EXE can be loaded from it just like a regular class library. There's no need to build it to a DLL.

Hans Passant
I never knew that, thanks for sharing, that makes life easier!