【问题标题】:NUnit test adapter: why is single test executed multiple times?NUnit 测试适配器:为什么单个测试执行多次?
【发布时间】: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


    【解决方案1】:

    如果您的 NUnit 版本是 3.0.1,为什么要使用 NUnit Adapter v2?

    【讨论】:

    【解决方案2】:

    您同时拥有 Visual Studio 扩展和 NUnit Test Runner 的 NuGet 包。

    从 Visual Studio 扩展中删除了测试适配器。 在工具菜单上,单击扩展管理器。 在扩展管理器中找到测试适配器并单击禁用或卸载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      相关资源
      最近更新 更多