我似乎没有正确过滤,我正在运行我不想运行的测试。
我有
MySolution (Solution)
MyProjectA.Tests
AAA.Tests
BBB.Tests
MyProjectB.Tests
AAA.Tests
devops 中的任务
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
testAssemblyVer2: |
**\bin\${{ parameters.buildConfiguration }}\**\*Tests*.dll
!**\obj\**
!**\xunit.runner.visualstudio.testadapter.dll
!**\xunit.runner.visualstudio.dotnetcore.testadapter.dll
platform: '${{ parameters.buildPlatform }}'
configuration: '${{ parameters.buildConfiguration }}'
searchFolder: '$(System.DefaultWorkingDirectory)'
otherConsoleOptions: '/platform:x64 /Framework:.NETCoreApp,Version=v3.1 /logger:console;verbosity="normal" '
我需要了解我如何才能
我该怎么做?我需要改变什么?
非常感谢
答案 0 :(得分:0)
您可以在 testFiltercriteria
任务上使用 VSTest@2
属性,这些任务引用 TestCaseFilter
Run tests that match the given expression.
<Expression> is of the format <property>=<value>[|<Expression>].
Example: /TestCaseFilter:"Priority=1"
Example: /TestCaseFilter:"TestCategory=Nightly|FullyQualifiedName=Namespace.ClassName.MethodName" Warning: The /TestCaseFilter command line option cannot be used with the /Tests command line option.
For information about creating and using expressions, see TestCase filter.
所以在你的情况下可能是
FullyQualifiedName=~MyProjectA
和
FullyQualifiedName=~MyProjectA.Tests.BBB
有关过滤请求的更多详细信息,请查看here
答案 1 :(得分:0)
只运行属于 MyProjectA 的测试
您可以在测试文件中指定项目名称:
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
testAssemblyVer2: |
**\MyProjectA.Tests\bin\${{ parameters.buildConfiguration }}\**\*Tests*.dll
!**\obj\**
...
<块引用>
在 MyProjectA 中只运行 BBB.Tests
您可以使用 Test filter criteria
过滤来自 BBB.Tests 的测试:
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
testAssemblyVer2: |
**\MyProjectA.Tests\bin\${{ parameters.buildConfiguration }}\**\*Tests*.dll
!**\obj\**
testFiltercriteria: 'TestCategory=BBB'
...