Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get started using Nunit in my Visual Studio project?

I want to start using Nunit (finally), I am using Visual Studio 2008.

Is it as simple as importing Nunit into my test project?

I remember seeing a GUI for NUnit, does that do the exact same thing that a separate test project would do, except show you the pass/fail visually?

like image 250
Blankman Avatar asked Nov 24 '08 19:11

Blankman


4 Answers

I like to add a link to NUnit in my external tools.

Under Tools->External Tools add NUnit

Title: &NUnit
Command: <path to nunit>
Arguments $(ProjectFileName) /run
Initial directory: $(ProjectDir)

After that you can quickly run it by compiling then hitting alt-t + n

like image 175
Noaki Avatar answered Oct 21 '22 04:10

Noaki


Yes, that's basically it. Personally I find the unit test runner which comes with ReSharper to be excellent - and the tool itself is well worth the licence feel. Alternatively there's TestDriven.NET.

Having a test project which runs nunit-gui or nunit-console separately is all very well, but you really want the whole unit testing experience to be as seamless as possible. The easier it is to write and run tests, the more likely you are to do it - which is a very good thing. Don't underestimate the gradual build-up of frustration due to a slightly poorer user experience, flipping between windows etc.

like image 44
Jon Skeet Avatar answered Oct 21 '22 05:10

Jon Skeet


NUnit is something that isn't inside Visual Studio 2008. It does have a console OR a graphical user interface (gui) that can be run both outside VS2008 OR can be attached to the process of VS2008 for debugging.

If you do want something inside VS2008 you need to have a third party pluging like ReSharper.

Edit: This has been answered in the past (not for VS2008 specificly but still relevant)

like image 27
Patrick Desjardins Avatar answered Oct 21 '22 03:10

Patrick Desjardins


I've used TestDriven.NET with VS2005, and it has changed how I develop and test code.

You can run all of the tests on any class, module, project, or solution. You can also run a test in the debugger, which is tremendously useful to diagnose and fix issues when they crop up.

like image 24
Adam Tegen Avatar answered Oct 21 '22 03:10

Adam Tegen