Search code examples
azure-devopsazure-pipelinesmstest

how to resolve no test matches the given testcase filter azure pipeline?


enter image description here Those unit test are executing in azure pipeline before swap. After executing everytime it's showing me this.

/TestAdapterPath:"F:\agents04_agent04\r2\a" 2023-10-12T20:10:01.1725408Z Starting test execution, please wait... 2023-10-12T20:10:04.1812614Z A total of 3 test files matched the specified pattern. 2023-10-12T20:10:04.2215572Z Blame: Attaching crash dump utility to process testhost.net472.x86 (19376). 2023-10-12T20:10:05.5133837Z No test matches the given testcase filter TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebServices in F:\agents04_agent04\r2\a\tests\DashboardApp.Deployment.Tests\DashboardApp.Deployment.Tests.dll F:\agents04_agent04\r2\a\tests\FtpLibrary.Tests\FtpLibrary.Tests.dll F:\agents04_agent04\r2\a\tests\Webservices.Deployment.Tests\Deployment.Tests.dll 2023-10-12T20:10:05.8662311Z Results File: F:\agents04_agent04_temp\TestResults\ga-build-vm$_ga-build-vm_2023-10-12_20_10_05.trx 2023-10-12T20:10:05.8907689Z Vstest.console.exe exited with code 0. 2023-10-12T20:10:05.8908174Z **************** Completed test execution ********************* 2023-10-12T20:10:05.8970097Z Test results files: F:\agents04_agent04_temp\TestResults\ga-build-vm$_ga-build-vm_2023-10-12_20_10_05.trx 2023-10-12T20:10:05.9203010Z No Result Found to Publish 'F:\agents04_agent04_temp\TestResults\ga-build-vm$_ga-build-vm_2023-10-12_20_10_05.trx'. 2023-10-12T20:10:06.1745166Z Created test run: 1240217 2023-10-12T20:10:06.1747100Z Publishing test results: 0

I tried to update MSTest framework and adding MSTestAdapter.


Solution

  • No test matches the given testcase filter TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebServices

    Based on the error message, it indicates that the test categories in the test class or test method do not meet the test case filter you set in the Pipeline task.

    The test category set in the test case filter needs to satisfy BeforeSwap, prod and webservice at the same time.

    From your screenshot of the unit test code, the categories are BeforeSwap,prod and Web API.

    You can try to change the test case filter to the value: TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebApi

    For example:

    - task: VSTest@2
      displayName: 'Test Assemblies'
      inputs:
        testAssemblyVer2: |
         **\$(BuildConfiguration)\*test*.dll
         !**\obj\**
        testFiltercriteria: 'TestCategory=BeforeSwap&TestCategory=prod&TestCategory=WebApi'
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'
    

    Or you can also check if the WebServices test category exists in your test categories definition and apply it to the actual test class.