【问题标题】:Vstest.console.exe can't find nunit testsVstest.console.exe 找不到 nunit 测试
【发布时间】:2017-11-28 19:00:29
【问题描述】:

我有 VS 2017 和 .net 4.6

在尝试使用 vstest.console 通过 cmd 提示符运行时:

vstest.console.exe bin\Release\Tests.dll /UseVsixExtensions:true

我收到警告“/bin/Release/test.dll 中没有可用的测试,请确保已安装的测试发现器和执行器、平台和框架版本设置正确,然后重试。”

所以,我尝试列出测试,但没有显示任何测试。

vstest.console.exe bin\Release\Tests.dll /ListTests /UseVsixExtensions:true

单元测试类文件如下所示。

[TestFixture]
public class class1
    {
    static void StartTest(string[] args)
    {

    }

 [Test] [Category("Regression_Test")]   
    public void TS1()
    {

    }
}

我尝试用谷歌搜索类似的问题,但没有找到任何可行的方法。非常感谢任何帮助

【问题讨论】:

    标签: selenium nunit vstest.console.exe


    【解决方案1】:

    您是否将 NUnit 3 测试适配器安装为 vsix?

    如果您使用更常用的通过 nuget 安装的方法,则需要使用 /TestAdapterPath 选项告诉 vstest.console.exe 在哪里可以找到适配器。

    【讨论】:

    • 我已经通过 Nuget 安装了 NUnit 3 测试适配器,/TestAdapterPath 是否需要指向 NUnit3.TestAdapter.dll? - 我无法让它工作......
    【解决方案2】:

    这样使用:

    "<full_path_of_exe>\vstest.console.exe" "<full_path_of_dll>\NUnitTestProject.dll" /TestAdapterPath:"<point_to_the_FOLDER_where_your_NUnit3.TestAdapter.dll_is>"
    

    【讨论】:

      【解决方案3】:

      就像查理已经提到的那样。只需在您的项目中安装 nuget 包,一切都很好!

      https://www.nuget.org/packages/NUnit3TestAdapter/


      未来将不再支持旧的 NUnit 3 测试适配器扩展!

      https://marketplace.visualstudio.com/items?itemName=NUnitDevelopers.NUnit3TestAdapter#overview

      注意:- 早期警告:请注意 VSIX 测试适配器将在即将推出的 Visual Studio 2019 中弃用。请将 nuget 适配器包添加到您的解决方案中。在此处和此处查看更多信息

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-04-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-09
        • 1970-01-01
        相关资源
        最近更新 更多