Where to find test results on azure build pipeline?

Viewed 3691

I can't find the right path configuration for my build pipeline.

The Publish Test Results task always ends with no files match warning.

Here the relevant part of the yaml file:

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    testFiltercriteria: 'TestCategory!=Local'

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'VSTest'
    testResultsFiles: '**/TestResults/*.trx'

Update Here the VSTest output:

**************** Completed test execution *********************
Test results files: D:\a\_temp\TestResults\VssAdministrator_fv-az111_2020-07-10_11_01_10.trx
Created test run: 38
Publishing test results: 155
Publishing test results to test run '38'.
TestResults To Publish 155, Test run id:38
Test results publishing 155, remaining: 0. Test run id: 38
Published test results: 155
Publishing Attachments: 1
Completed TestExecution Model...
Finishing: VSTest

The mask should catch the trx file.

2 Answers

If you check the build log of VSTest task, you will find where the test Results file is stored.

enter image description here

By default the results are stored in $(Agent.TempDirectory)/TestResults.

So you can set the searchFolder attribute of PublishTestResults task to $(Agent.TempDirectory)/TestResults. See below:

- task: PublishTestResults@2
  displayName: 'Publish Test Results'
  inputs:
    testResultsFormat: VSTest
    testResultsFiles: '**/*.trx'
    searchFolder: '$(Agent.TempDirectory)\TestResults'

Another way to set the resultsFolder attribute of VSTest task to customize the test result output place. See below:

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    testFiltercriteria: 'TestCategory!=Local'
    resultsFolder: '$(System.DefaultWorkingDirectory)\TestResults'

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'VSTest'
    testResultsFiles: '**/TestResults/*.trx'   

In above example, i specified the resultsFolder of vstest task to folder$(System.DefaultWorkingDirectory)\TestResults. So the test results file will be stored in this folder.

The easiest way is to not use PublishTestResults task if the testcases are run Vstest task, as the thread in above comment mentioned. Vstest task will publish the test result automatically.

Other built-in tasks such as Visual Studio Test task and Dot NetCore CLI task automatically publish test results to the pipeline, while tasks such as Ant, Maven, Gulp, Grunt, .Net Core and Xcode provide publishing results as an option within the task. If you are using any of these tasks, you do not need a separate Publish Test Results task in the pipeline.

Try setting it as

 testResultsFiles: '**/*.trx' 
Related