How do I run NUnit in debug mode from Visual Studio?
Posted
by Jon Cage
on Stack Overflow
See other posts from Stack Overflow
or by Jon Cage
Published on 2009-04-17T10:11:47Z
Indexed on
2010/03/28
11:43 UTC
Read the original article
Hit count: 258
I've recently been building a test framework for a bit of C# I've been working on. I have NUnit set up and a new project within my workspace to test the component. All works well if I load up my unit tests from Nunit (v2.4), but I've got to the point where it would be really useful to run in debug mode and set some break points.
I've tried the suggestions from several guides which all suggest changing the 'Debug' properties of the test project:
Start external program: C:\Program Files\NUnit 2.4.8\bin\nunit-console.exe
Command line arguments: /assembly: <full-path-to-solution>\TestDSP\bin\Debug\TestDSP.dll
I'm using the console version there, but have tried the calling the GUI as well. Both give me the same error when I try and start debugging:
Cannot start test project 'TestDSP' because the project does not contain any tests.
Is this because I normally load \DSP.nunit into the Nunit GUI and that's where the tests are held?
I'm beginning to think the problem may be that VS wants to run it's own test framework and that's why it's failing to find the NUnit tests?
[Edit] To those asking about test fixtures, one of my .cs files in the TestDSP project looks roughly like this:
namespace Some.TestNamespace
{
// Testing framework includes
using NUnit.Framework;
[TestFixture]
public class FirFilterTest
{
/// <summary>
/// Tests that a FirFilter can be created
/// </summary>
[Test]
public void Test01_ConstructorTest()
{
...some tests...
}
}
}
...I'm pretty new to C# and the Nunit test framework so it's entirely possible I've missed some crucial bit of information ;-)
[FINAL SOLUTION] The big problem was the project I'd used. If you pick:
Other Languages->Visual C#->Test->Test Project
...when you're choosing the project type, Visual Studio will try and use it's own testing framework as far as I can tell. You should pick a normal c# class library project instead and then the instructions in my selected answer will work.
© Stack Overflow or respective owner