且构网

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

如何在visual studio 2010中运行Nunit测试

更新时间:2023-02-10 23:19:52

适用于Visual Studio的NUnit 3.0测试适配器



NUnit 3.0测试适配器允许您在Visual Studio中运行NUnit 3.0测试。这是一个新的适配器,部分基于原始NUnit测试适配器的代码,但已修改为与NUnit 3.0一起使用。



无法运行NUnit 2 .x测试使用此适配器。为此目的使用原始适配器。如果您需要使用NUnit 2.x和其他使用NUnit 3.0的项目处理项目,您可以安装适配器的两个版本。



NUnitLite Runner



要在NUnitLite下运行测试,请按以下步骤操作:



1.创建一个控制台应用程序,用作测试程序集。如果您已经在dll中放置了测试,则可以更改项目以便生成控制台应用程序并重新加载它。

2.确保测试程序集同时引用nunit.framework和nunitlite。 br />
3.控制台应用程序的Main()看起来应该是这样的......

NUnit 3.0 Test Adapter for Visual Studio

The NUnit 3.0 Test Adapter allows you to run NUnit 3.0 tests inside Visual Studio. This is a new adapter, based partly on the code of the original NUnit Test Adapter, but modified to work with NUnit 3.0.

It is not possible to run NUnit 2.x tests using this adapter. Use the original adapter for that purpose. If you need to work with projects using NUnit 2.x and other projects using NUnit 3.0, you may install both versions of the adapter.

NUnitLite Runner

To run tests under NUnitLite, proceed as follows:

1. Create a console application to use as your test assembly. If you have already placed tests in a dll, you can change the project so that it produces a console application and reload it.
2. Make sure your test assembly references both nunit.framework and nunitlite.
3. The Main() for your console application should look something like this...
public static void Main(string[] args)
{
  new AutoRun().Execute(args);
}



4.执行测试应用程序以运行测试。


4. Execute your test application in order to run the tests.