views:

821

answers:

7

I have been running Visual Studio 2008 Team Edition for some time now and need to start using nunit. I loaded nunit 2.4.8 but nunit is not showing as a selection for a testing framework. This is the selection you see when starting a new project and it asks if you want to setup a testing project and which framework you wish to use (only displays Visual Studio Unit Test).

EDIT: The only choice I do get is the "Visual Studio Unit Test" the one installed with VS2008. I have only tried it in a new MVC project. I will try in some other project types and see what choices I get. Trying web project and winforms, unit testing isn't an option at the start of the project; which somewhat makes sense to me.

Update: I found a setting in the nuit GUI interface at Tools > Options; from the options tree IDE Support > Visual Studio. There is a checkbox to enable Visual Studio Support. I thought it was a home run, but after checking it, restarting apps, XP, etc. still the same issue where nunit isn't an option as a testing framework.

I know this should work as I described as Stephen Walther used nunit in his tutorial video with Charlie Poole of nunit.

A: 

It doesn't really matter as all you need to do is create a new class library project and add a reference to nunit.framework.dll and you are good to go.

Andrew Peters
A: 

Nunit does not offer built-in Visual Studio integration. There might be 3rd party solutions you can try. As far as I know, you create Nunit tests by adding the references to the Nunit libraries in a normal class library. You run the tests in a separate test runner outside of Visual Studio.

There are other ways to integrate Team Foundation Server with Nunit. For example you can use custom build tasks to integrate the Nunit tests into your TFS build process.

davogones
+1  A: 

Integrated testing with nUnit is available in ReSharper...(this is just one of the fine features of this product) I use it all the time.

Apparently it's also available with TestDriven.NET (I haven't used this product)

Jason Punyon
I use TestDriven daily. It's great. Obviously, having a nice GUI like NUnit or tying those test results into TFS is a necessary option when you've got a huge suite of tests, but when you need something simple to kick off tests you are in the process of writing, it's perfect.
joshua.ewer
+2  A: 

The Visual Studio integration is not provided by NUnit currently. However, you can create templates yourself that work the same way. For NUnit, you can find instructions and templates created from those instructions. There are also templates that others have created, you just need to google for them.

From the comments to the Walther/Poole video, this appears to be the method used to get the NUnit option for that demo.

Steven Lyons
+1  A: 

Alright.. seems like a MVC Tooling goodie.. not available for the rest of us. Found this link that seems to do what you want...

ASP.NET MVC Test Framework Integration

You need to mess around with the registry to get NUnit registered as a testing framework. See Step 2.

Gishu
+1  A: 

The template that Stephen Walther used can be found here: ASP.Net MVC Test framework integration. This link provides working demos whereas Gishu's link only provides all the registry magic. The demos are horribly out of date and not practically useful in their current state, but you could fix them up to suit your needs.

Ben Robbins
horribly out of date is August of 2008?
Brettski
The link I posted is from March 2008. You have to edit the templates if you want them to work.
Ben Robbins
+1  A: 

I found that my post here is a duplicate: http://stackoverflow.com/questions/21137/asp-net-mvc-and-nunit#23481

The accepted answer: http://stackoverflow.com/questions/21137/asp-net-mvc-and-nunit#23481

I must say I am pretty disappointed that Charlie Poole hasn't released a template which works with nunit and vs2008. I really don't wish to build my own and don't know enough about templates to know how worthy one is from someone else.

The last three responses to this post (thank you for the response) say the same thing so I am not sure who will get the accepted answer. laugh

According to the MVC site comments this may be the template used in the tutorial. No response from the presenters, as usual.

Brettski