我有一个非常基本的测试示例使用NUnit 3.0.1,NUnitTestAdapter.WithFramework 2.0.0和RestSharp 105.2.3,在Visual Studio 2015中用C#编写。当使用NUnit测试适配器运行测试时,我的测试执行了2次而不是1.似乎2个测试适配器并行运行。可能是什么原因?当然,我希望它只运行一次。提前谢谢!
using NUnit.Framework;
using RestSharp;
using System;
namespace Project1.Tests
{
public class Test1
{
[Test]
public void GetTest()
{
var client = new RestClient("http://www.thomas-bayer.com/sqlrest/");
var request = new RestRequest("CUSTOMER", Method.GET);
var queryResult = client.Execute(request);
Console.Write("result: " + queryResult.Content.Length);
Assert.IsTrue(queryResult.Content.Length > 0);
}
}
}
结果:
NUnit VS Adapter 2.0.0.0 discovering tests is started
NUnit VS Adapter 2.0.0.0 discovering tests is started
NUnit VS Adapter 2.0.0.0 discovering test is finished
NUnit VS Adapter 2.0.0.0 discovering test is finished
A test with the same name 'Project5.Tests.Test1.GetTest' already exists. This test is not added to the test window.
========== Discover test finished: 2 found (0:00:00,1950195) ==========
------ Run test started ------
NUnit VS Adapter 2.0.0.0 executing tests is started
Loading tests from E:\Testing\RestVS\Project5\Project5\bin\Debug\Project5.dll
Run started: E:\Testing\RestVS\Project5\Project5\bin\Debug\Project5.dll
result: 4672
NUnit VS Adapter 2.0.0.0 executing tests is finished
NUnit VS Adapter 2.0.0.0 executing tests is started
Loading tests from E:\Testing\RestVS\Project5\Project5\bin\Debug\Project5.dll
Run started: E:\Testing\RestVS\Project5\Project5\bin\Debug\Project5.dll
result: 4672
NUnit VS Adapter 2.0.0.0 executing tests is finished
========== Run test finished: 1 run (0:00:06,0725361) ==========
答案 0 :(得分:0)
如果您的NUnit版本是3.0.1,为什么使用NUnit Adapter v2?
答案 1 :(得分:0)
您同时拥有NUnit Test Runner的Visual Studio扩展和NuGet包。
从Visual Studio扩展中删除了测试适配器。 在工具菜单上,单击扩展管理器。 在Extension Manager中找到The Test adapter并单击disabled或uninstall。