【发布时间】:2015-12-10 10:42:59
【问题描述】:
我有一个非常基本的测试示例,使用 NUnit 3.0.1、NUnitTestAdapter.WithFramework 2.0.0 和 RestSharp 105.2.3,在 VisualStudio 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) ==========
【问题讨论】:
标签: visual-studio-2015 nunit restsharp