【问题标题】:Using Nunit3-Console.exe to run specflow tests but detects tests from only one namespace使用 Nunit3-Console.exe 运行 specflow 测试,但仅检测来自一个命名空间的测试
【发布时间】:2020-05-04 20:17:22
【问题描述】:

构建环境

项目语言:C#

.net 框架 4.5

OpenCover 版本 2.5.3427

Specflow 2.3 版

Nunit 版本 3.11.0

要求

在构建期间,用户将选择多个子系统验收测试,我需要为这些子系统运行测试。所有测试都在同一个程序集中,但由文件夹(命名空间)分隔

我正在运行以下命令

"D:\DEVOPS_TOOLSET\opencover.4.5.3427\OpenCover.Console.exe" -filter:"+[Project.AcceptanceTests]Project.AcceptanceTests.Geometry,Project.AcceptanceTests.Arithmentic  -[nunit*]*" -target:"D:\DEVOPS_TOOLSET\NUnit.ConsoleRunner.3.11.1\tools\nunit3-console.exe" -targetargs:"Project.AcceptanceTests\bin\Release\Project.AcceptanceTests.dll --framework:net-4.5 --result:UnitTestResults.xml --labels=Before --where \"namespace == Project.AcceptanceTests.Geometry || namespace == Project.AcceptanceTests.Arithmentic\" --trace=Debug" -output:OpenCoverOutput.xml

该命令仅检测来自“Geometry”命名空间的测试,而根本不检测来自“Arithmetic”命名空间的测试。

在使用 --Where 选项从多个命名空间运行测试时需要帮助

已尝试在命名空间的 where 条件中使用 ||&&

已尝试在命名空间的 where 条件中使用 ORand

到目前为止没有运气。

任何帮助将不胜感激

【问题讨论】:

  • 更新:命名空间“几何”和“算术”具有包含测试夹具的单独类

标签: c# specflow nunit-3.0 opencover


【解决方案1】:

经过一些实验,我发现以下命令有效

"D:\DEVOPS_TOOLSET\opencover.4.5.3427\OpenCover.Console.exe" -filter:"+[Project.AcceptanceTests]Project.AcceptanceTests.Geometry,Project.AcceptanceTests.Arithmentic  -[nunit*]*" -target:"D:\DEVOPS_TOOLSET\NUnit.ConsoleRunner.3.11.1\tools\nunit3-console.exe" -targetargs:"Project.AcceptanceTests\bin\Release\Project.AcceptanceTests.dll --framework:net-4.5 --result:UnitTestResults.xml --labels=Before --where \"namespace == ^'Project.AcceptanceTests.Geometry^' OR namespace == ^'Project.AcceptanceTests.Arithmentic^'\" --trace=Debug" -output:OpenCoverOutput.xml

此链接帮助我解决了问题 Run all tests in namespace using Nunit3-console.exe

还验证了选定的命名空间具有可用的适当测试装置

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多