我如何从Visual Studio调试模式下运行NUnit的? [英] How do I run NUnit in debug mode from Visual Studio?

查看:137
本文介绍了我如何从Visual Studio调试模式下运行NUnit的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在为建设一个位的C#我一直在测试框架。我有NUnit的设置和我的工作区中的一个新的项目,以测试该组件。一切运作良好,如果我从NUnit的(V2.4)加载了我的单元测试,但我已经得到的地步,这将是在调试模式下运行,真正有用的,并设置一些破发点。

我试着从几个导游,所有建议改变测试项目的调试属性建议:

 启动外部程序:C:\\ Program Files文件\\ NUnit的2.4.8 \\ BIN \\ NUnit的,console.exe
命令行参数:/集:其中;全路径实现解决方案> \\ TestDSP \\ BIN \\调试\\ TestDSP.dll

我使用控制台版本存在,但试图调用图形用户界面为好。这两个给我同样的错误,当我试着开始调试:

 无法启动测试项目TestDSP,因为该项目不包含任何测试。

这是因为我通常加载\\ DSP.nunit到NUnit的GUI而这也正是测试举行?

我开始觉得问题可能是VS想要运行它自己的测试框架,这就是为什么它的失败找到NUnit的测试?

修改:对于那些询问测试夹具,在TestDSP项目我的.cs文件,一个看起来大致是这样的:

 命名空间Some.TestNamespace
{
    //测试框架包括
    使用NUnit.Framework;    [的TestFixture]
    公共类FirFilterTest
    {
        [测试]
        公共无效Test01_ConstructorTest()
        {
            ......一些测试...
        }
    }
}

...我pretty新的C#和NUnit测试框架,所以它是完全有可能我已经错过了一些信息的关键位; - )

最终解决方案:最大的问题是我已经使用的项目。如果你选择其他语言 - >的Visual C# - >测试 - >测试项目 ...当你选择的项目类型,Visual Studio会尝试使用它自己的测试框架,据我可以告诉。你应该选择一个正常 C#类库项目来代替,然后我选择的答案中的指令工作。


解决方案

我用同样的技术,因为你正在尝试乔恩,没有/装配标记,即

 启动外部程序:C:\\ Program Files文件\\ NUnit的2.4.8 \\ BIN \\ nunit.exe命令行参数:<路径> \\ BIN \\调试\\ Quotes.Domain.Tests.dll

是否TestDSP.dll包含所有TestFixtures?

>启动新实例

-

作为我的测试项目是不是在解决方案中的启动项目,我通过在测试项目上右击并选择调试运行我的测试

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
    {
        [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.

解决方案

I use the same technique as you are trying Jon, without the /assembly flag, i.e.

Start External Program: C:\Program Files\NUnit 2.4.8\bin\nunit.exe

Command line arguments: "<path>\bin\Debug\Quotes.Domain.Tests.dll"

Does TestDSP.dll contain all your TestFixtures?

As my test project is not the startup project in the solution, I run my tests by right-clicking on the test project and choosing Debug --> Start New Instance

这篇关于我如何从Visual Studio调试模式下运行NUnit的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆