建设环境
项目语言。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条件中
已试过 OR
和 and
的where条件中
到目前为止,没有运气。
任何帮助将被感激
经过一些实验,我发现下面的命令是可行的。
"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
这个链接帮助我解决了这个问题使用Nunit3-console.exe运行命名空间中的所有测试。
还验证了选定的命名空间是否有适当的测试装置。
谢谢你