How do I run NUnit in debug mode from Visual Studio?

后端 未结 19 1238
闹比i
闹比i 2020-11-30 17:59

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 wor

相关标签:
19条回答
  • 2020-11-30 18:24

    I got the same error with MSTest. I found that in the Test Output window, some of the tests had duplicate IDs and could not be loaded. I removed all duplicate tests and now I was able to run the tests when i start the project.

    0 讨论(0)
  • 2020-11-30 18:25

    Install TestDriven.NET, which is a plugin for Visual Studio

    From there you can right click on your unit test assembly and click Run Tests to run the whole suite, right click on a TestFixture class to run just the tests in that class, or right click on a Test method to run just that method.

    You also have the option to Test With Debugger, if you need to breakpoint into your tests in debug mode.

    0 讨论(0)
  • 2020-11-30 18:28

    Try NUnitit - a open source Visual Studio Addin for Debugging NUnit Test cases

    HomePage - http://nunitit.codeplex.com/

    0 讨论(0)
  • 2020-11-30 18:28

    If you are able to get the console / or GUI working, but your breakpoints are not being hit, it may be because your app is running a different .NET runtime than NUnit is. Check to see if your nunit-console.exe.config / nunit.exe.config has the runtime specified.(The configurations live in the same directory as the nunit exe's.) Specify the runtime using the startup node:

    <configuration>
        <startup>
           <supportedRuntime version="4.0" />
        </startup>
    
    0 讨论(0)
  • 2020-11-30 18:31

    If project path contains spaces e.g. "New Project" in path <path>\bin\Debug\New Project\Quotes.Domain.Tests.dll then enclose the Start Option --> Command Line Arguments project path in double quotes.

    I spent a lot of time to figure this out.

    0 讨论(0)
  • 2020-11-30 18:34

    When I need to debug my NUnit tests, I simply attach to the NUnit GUI application nunit-agent.exe using "Debug|Attach to Process" and run the tests from the GUI. Any breakpoints in my tests (or the code they're testing) are hit. Am I misunderstanding your question, or will that work for you?

    0 讨论(0)
提交回复
热议问题