Nunit-未发现测试[没有错误消息] [英] Nunit - doesn't discover tests [no error-message]

查看:155
本文介绍了Nunit-未发现测试[没有错误消息]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Unit拒绝在程序集中显示或运行我的测试.如果Unit生成诸如无法在装配中找到测试"之类的错误消息,则不是这种情况.它只是发现我没有考试.

Unit refuses to dsicover or run my tests in an assembly. This is not the case where Unit produces an error message like "Unable to find test in assembly". It simply doesn't discover that I have tests.

我右键单击测试方法,测试输出显示:

I right-click the test-method and the test output shows:

发现测试开始------ 发现测试完成:找到0个(0:00:00,0260026)"

Discover test started ------ Discover test finished: 0 found (0:00:00,0260026)"

我已经尝试了这篇文章中提到的所有内容: NUnit在组装中找不到测试

I have tried everything mentioned in this post: NUnit doesn't find tests in assembly

升级不是可能.处理器体系结构设置正确.我的测试是公开的,并具有所有正确的标签.

Upgrading is not a possiblity. The processor architecture settings are correct. My tests are public and have all the correct tags.

这是我项目中的一些代码,我什至无法执行.我知道这是因为我一开始就有一个断点.

Here's some code from my project that I simply can't get to even execute. I know that because I have a break-point right at the beginning.

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

namespace UnitTestProjects
{
    [TestFixture]
    public class SomeRandomTests
    {
        [Test]
        public void ShouldFail()
        {
            Assert.AreEqual(1, 0);
        }

        [Test]
        public void ShouldPass()
        {
            Assert.AreEqual(1,1);
        }
    }
}

我正在运行内部Visual Studio测试资源管理器.单元框架版本2.5.9.10348,运行时版本v2.0.50727.我已经安装了单元测试采用者.我尝试重新安装它,但没有成功.

I'm running the internal visual studio test explorer. Unit Framework version 2.5.9.10348, runtime version v2.0.50727. I have Unit Test Adopter installed. I've attempted reinstalling it with no success.

推荐答案

您必须安装NUnit VSAdapter vsix扩展,或者将适配器作为nuget软件包添加到您的解决方案中.

You must either install the NUnit VSAdapter vsix extension, or add the adapter as nuget package to your solution.

最新版本是2.0,并且可以在此处获得vsix: https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d

The latest version is the 2.0, and the vsix is available here: https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d

和nuget包可以在这里找到: http://www.nuget.org/packages/NUnitTestAdapter/

And the nuget package can be found here: http://www.nuget.org/packages/NUnitTestAdapter/

有关这些选项的更多信息,请参见MSDN ALM帖子

More information on these options can be found in this MSDN ALM post http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/11/part-3-unit-testing-with-traits-and-code-coverage-in-visual-studio-2012-using-the-tfs-build-and-the-new-nuget-adapter-approach.aspx, which also points to two earlier posts.

如果在测试"下的输出"控制台窗口中查看,适配器名称和版本将在运行时显示在其中.如果没有出现,则说明适配器未处于活动状态.

If you look in the Output console window under Test, the adapter name and version is displayed there as it run. If it doesn't come up, the adapter is not active.

如果运行Resharper,请确保您具有最新的8.2版本,之前与测试适配器和Resharper会有冲突.

If you run Resharper, ensure you have the latest 8.2 version, there has been conflicts earlier with the test adapters and resharper.

即使您不能将该项目从NUnit 2.5.9升级到最新的2.6.4,也可以使用2.6.4验证适配器在测试项目中是否正常工作.
我只是使用NUnit 2.5.9在我自己的机器上进行了检查,并且与2.0适配器配合使用时效果很好.

Even if you can't upgrade this project from NUnit 2.5.9 to latest 2.6.4, you can verify the adapters work correctly in a test project using 2.6.4.
I just checked on my own machine with NUnit 2.5.9, and that worked nice with the 2.0 adapter.

更新:

对于VS2017,您无需安装NUnit VSAdapter vsix扩展,而应先安装适用于Visual Studio 2012的NUnit 3 TestAdapter(更新1).可以与NuGet软件包一起使用:NUnit 3.9.0.

For VS2017 you dont install the NUnit VSAdapter vsix extension, instead install the NUnit 3 TestAdapter for Visual Studio 2012 (Update 1) onwards. This works with NuGet package: NUnit 3.9.0.

更新2-六月2019 刚刚发布了NUnit2适配器的2.2版本.现在,它应该可以与SDK类型的项目以及VS 2017和2019正常使用.

Update 2 - June 2019 Just released the 2.2 version of the NUnit2 Adapter. It should now work properly with SDK type projects, and with VS 2017 and 2019.

这篇关于Nunit-未发现测试[没有错误消息]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆