0

I have a solution that has multiple projects including NUnit Test projects. So the solution looks like this (using generic names, these aren't the actual names):

+ Solution
  + Project1
  + Project1.Test
  + Project2
  + Project2.Test
  + Project3
  + Project3.Test
  ...

I would like to run all the NUnit Tests through the NUnit GUI or console application when I click 'Start Debugging' from within Visual Studio.

Right now, what I have done is added a new Class library called TestRunner and set it to be the StartUp project (I've read I don't really need to do this, I can just right click on the project and click 'Debug > Start new instance'). Then inside the project properties on the Debug page, I set the 'Start Action' to 'Start external program' and select the nunit-console.exe (Looks like nunit.exe GUI doesnt support multiple assemblies as input parameters). Then in the 'Command line arguments' I enter the path to each of the projects. Like this:

Setup

This seems to work OK, but I'm wondering if there is a better way to do this (maybe I don't need an extra project, or there might be an easier way to run multiple NUnit Test projects from within Visual Studio).

Any suggestions on improving this would be appreciated. Running NUnit 2.5.9 and Visual Studio 2008.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184

1 Answers1

4

There are various test runner extensions for Visual Studio itself - personally I use ReSharper (commercial) and also NCrunch (used to be free, now commercial), although the latter is more of a continuous test tool than a "run explicitly" tool. If you're using Visual Studio non-Express, you should really look at running tests integrated into the IDE - it's much, much nicer than switching between apps.

However, if you want to run the NUnit GUI, just set up an NUnit project configuration which includes all your test projects - you'll only need to do that once, then you can use it however you run the tests.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I tried adding the main project to NUnit's GUI, but it didnt pick up the Tests. Looks like id have to add each project individually. – SwDevMan81 Feb 03 '12 at 15:18
  • +1 for mentioning ReSharper. They have a "Run All Tests from Solution" option which is beautiful. They also have a GUI for selecting tests to run. – Keith Feb 03 '12 at 15:21
  • @SwDevMan81: Don't add "the main project" - add the *solution*. However, even if that doesn't work, you should be able to add the DLLs once, and then you'll be able to run all the tests easily from Visual Studio, nunit console or nunit gui. – Jon Skeet Feb 03 '12 at 15:22
  • @JonSkeet: I only see the option in the NUnit GUI for 'Project > Add VS Project...' which only allows selecting csproj files. By adding all the DDLs and running them from Visual Studio, do you mean setting the external program to run as nunit.exe and supplying the NUnit Test Project (.nunit) as the input file? I guess this could work, let me try – SwDevMan81 Feb 03 '12 at 15:29
  • @SwDevMan81: Yes, that's what I meant - sorry about the misleading info about the solution files; I really thought NUnit would use those... – Jon Skeet Feb 03 '12 at 15:43
  • @JonSkeet: No problem. I used the .nunit file like you suggested and I'm able to run the GUI from Visual Studio. Thanks for your help. – SwDevMan81 Feb 03 '12 at 15:46
  • Looks to me like NCrunch is not free (anymore?) or is there something I've overlooked? – NobodysNightmare May 06 '13 at 14:00
  • @NobodysNightmare: Nope, just a matter of time. It used to be free, but isn't now. I've edited the answer, thanks. – Jon Skeet May 06 '13 at 14:01