views:

567

answers:

6

I'm developing in vs2008, c#, .net 3.5.

I downloaded NUnit 2.5 win / msi version. I have created a [TestFixture] Class containing several [Test] methods.

How do I run the tests?

When I run a NUnit demo solution from Ed Ames, his test .cs files have an icon in the grey column to the left of the code (same place where breakpoints, bookmarks, etc show up.) Clicking on the icon gives me an option to run the tests.

That icon is not showing up in my projects. Is there a property I need to set?

Also, the documentation refers to a NUnit GUI that can be used to run the tests. A GUI doesnt seem to have downloaded in the msi version of NUnit. Is there a separate download for the Gui?

+1  A: 

The demo you saw most likely had a VS plug in (Resharper, TestDriven.NET, etc.), which doesn't come with NUnit. However, NUnit installs with a GUI. Go to the folder that you installed NUnit and you will find it there.

The program is called nunit.exe and it's in the bin folder.

Once you start it, you'll need to go to File -> Open Project and find the DLL you built in Visual Studio

Joseph
A: 

You have to open the dll with 1) Nunit command line or 2) Nunit GUI

phsr
A: 

What you probably saw was Resharper's GUI (or something similar). Worth getting it, IMO.

Otávio Décio
A: 

You can use the nUnit runner (GUI - nunit.exe in the bin folder, Console - nunit-console-x86.exe) which comes with nUnit I believe.

Alternatively, if you have resharper (http://www.jetbrains.com/resharper/) installed, it has a test runner.

There is also TestDriven.Net (http://www.testdriven.net/)

cbeuker
+1  A: 

I haven't seen this demo, but it sounds very much like he is using Resharper.

If you ran the msi installer, it will have installed the NUnit GUI runner. If you browse your start menu its likely under Programs -> Nunit. From the GUI runner you can load your test assembly by navigating to the bin directory of your project.

BenA
+6  A: 

Thanks for all your help guys.

I am using resharper, forgot to mention it.

Actually, tests were not running (no tests found in file) because my [TestFixture] class was not Public. Changed it to Public and all my tests showed up.

Also, thanks for your help finding the Gui. I was looking for an exe with GUI in the filename. But I will use Resharper to run the tests. Now that I have found them!

Lill Lansey
Thanks, this comment solved my problem!Just a heads-up: apparently the R# testrunner doesn't support the entire feature-set of NUnit. ExpectedException and TestCase in particular.
Tomas
Thanks for the tip. Just wasted 10 minutes scratching my head over this damn "No tests found in file" error. It was because my test class wasn't public!
NathanE