且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调试在Visual Studio 2010 NUnit测试

更新时间:2023-02-21 07:53:36

假设你正在使用的不是速成版,然后 TestDriven.NET 可能会使用。

Assuming you're using a version of Visual Studio other than Express Edition then TestDriven.NET might be of use.

在安装后,它


  1. 设置您的测试方法中的一个断点

  2. 从一测试单击并选择调试器由于菜单

  3. 调试器应启动并打你的断点

不幸的是你不能因为TestDriven.NET是Visual Studio的一个插件和Express版本不支持使用插件

Unfortunately you can't use this method with Express editions of visual studio because TestDriven.NET is a plugin for visual studio and the Express editions do not support the use of plugins

您也可以运行通过一个控制台应用程序在调试器测试:

You can also run a test in the debugger via a console application:


  1. 创建一个新的控制台应用程序

  2. 引用的单元测试项目

  3. 里面的主要方法控制台应用程序创建测试fixuture的新实例,然后调用的测试方法之一。例如,如果我有一个名为夹具和MyTests名为Test1的测试中,我会写:

  1. Create a new console application
  2. Reference your unit tests project
  3. Inside the Main method of the console application create a new instance of your test fixuture and then call one of the test methods. For example if I have a fixture named MyTests and a test named Test1 I'd write:

var myTests = new MyTests();
myTests.Test1();


  • 将在该行设置一个断点,你创建 MyTests 类,并按F5