【问题标题】:Tests not showing up in Test Explorer (Nunit)测试资源管理器 (Nunit) 中未显示测试
【发布时间】:2016-12-02 01:08:22
【问题描述】:

问题:我的 NUnit 测试没有显示在测试资源管理器中。

我目前在 64 位机器上运行 Visual Studio Express 2013。目前,我安装了“NUnit TestAdapter,包括 NUnit 2.6.4 框架”。框架版本为2.6.4.14350,测试适配器版本为2.0.0.0

按照这两个线程(NUnit Unit tests not showing in Test Explorer with Test Adapter is installed 和 Visual Studio 2013 doesn't discover unit tests)进行故障排除:

  • 目前,“Active Solution Platform”设置为 64 位进行构建 我的测试项目的设置(构建 > 配置管理器)。

  • “默认处理器体系结构”指向被测 64 位 > 测试设置。

  • 已引用 NUnit 框架和 TestAdapter 在测试项目中指定。

  • 测试项目的 cs 文件在正确的位置包含 [TestFixture] 和 [Test]
  • 我已尝试多次清理/重建解决方案
  • 我已尝试多次重启 Visual Studio
  • 我已尝试通过“以管理员身份运行”运行 Visual Studio
  • 我已尝试运行 NUnit 版本 3(框架和测试适配器)

下面是我的代码:

using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hello_World_Testing
{
    [TestFixture]
    public class HelloWorldTesting
    {
        [Test]
        public void subtract()
        {
            int value = 1;

            if (value == 1)
            {
                Assert.Pass();
            }
        }

        [Test]
        public void addition()
        {
            int firstValue = 1;
            int secondValue = 2;

            Assert.AreEqual(3, firstValue + secondValue);
        }
    }
}

【问题讨论】:

  • 如果 NUnit 适配器出现错误,它们应该会显示在 Visual Studio 的输出窗口中的 Test 下拉列表中。有什么吗?
  • 嗨,罗伯。在输出下,找到 0。没有错误信息。完整消息: ------ 发现测试开始 ------ 发现测试完成: 0 found (0:00:02.6861536)
  • 你能用 NUnit 控制台运行你的测试吗?它可能会揭示更多有用的错误。
  • 是的,我可以。我已经修剪了顶部,但关键部分:
  • 你使用的是扩展程序还是运行者的nuget?另外,你的测试不能是 AnyCPU 有什么原因吗?

标签: unit-testing visual-studio-2013 nunit


【解决方案1】:

我遇到了这个问题,这对我有用。

关闭 Visual Studio 前往:

C:/Users/YourUsername/AppData/Local/Temp

重命名文件名为:VisualStudioTestExplorerExtensions

-打开 Visual Studio 并重建解决方案

【讨论】:

  • 感谢您选择此作为答案,如果它符合其目的:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多