6

我有 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()
    {

    }
}

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

4

3 回答 3

8

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

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

于 2017-11-29T18:33:46.447 回答
1

使用这种方式:

"<full_path_of_exe>\vstest.console.exe" "<full_path_of_dll>\NUnitTestProject.dll" /TestAdapterPath:"<point_to_the_FOLDER_where_your_NUnit3.TestAdapter.dll_is>"
于 2021-02-05T21:04:35.533 回答
-1

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

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


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

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

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

于 2018-11-29T09:45:11.097 回答