To exclude specific tests using VSTest@2, you can leverage the testAssemblyVer2
input property in conjunction with the |
notation to define multiple patterns.
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
# note the |
testAssemblyVer2: |
**\*_uTest.exe
!**\*BBE*
In this example:
**\*_uTest.exe
: This pattern matches all files ending with_uTest.exe
in any folder.!**\*BBE*
: This pattern excludes any file or folder containingBBE
in its name.
The |
notation is crucial here as it allows you to specify multiple patterns on different lines. Without it, all lines would be treated as a single input, resulting in incorrect behavior.
Alternatively, you can use the testFiltercriteria
input property to exclude specific tests based on their fully qualified name:
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*_AlluTests.dll
testFiltercriteria: 'FullyQualifiedName!~TestCase1&FullyQualifiedName!~TestCase2'
Here, the testFiltercriteria
is set to FullyQualifiedName!~TestCase1&FullyQualifiedName!~TestCase2
, which excludes tests with the fully qualified names TestCase1
and TestCase2
.