unit-testingazure-devopsazure-pipelinesvstest

Azure Pipelines VSTest how to set name for TRX file


When i run my tests using the task VSTest@2 in Azure Pipelines, it generates a temporary .TRX file, I want to generate the same file but with a specific name:

It's generating like Administrator_TFSAGNT1533-1_2022-07-20.11_50_19.trx

I'd like to generate something like testResults.trx

My task

  - task: VSTest@2
    displayName: Unit Tests
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: '*(*.Test)*(*.Integration).dll'
      searchFolder: '$(Agent.BuildDirectory)\git\test-bin'
      resultsFolder: '$(Agent.BuildDirectory)\git\testsResult\unitTest'
      vsTestVersion: 'toolsInstaller'
      testFiltercriteria: 'TestCategory!=Integration'
      runSettingsFile: 'CodeCoverage.runsettings'
      codeCoverageEnabled: true

Solution

  • Figure it out: I had to add the line otherConsoleOptions: '/Logger:"trx;LogFileName=testResults.trx"'

          - task: VSTest@2
        displayName: Unit Tests
        inputs:
          testSelector: 'testAssemblies'
          testAssemblyVer2: '*(*.Test)*(*.Integration).dll'
          searchFolder: '$(Agent.BuildDirectory)\git\test-bin'
          resultsFolder: '$(Agent.BuildDirectory)\git\testsResult\unitTest'
          vsTestVersion: 'toolsInstaller'
          testFiltercriteria: 'TestCategory!=Integration'
          runSettingsFile: 'CodeCoverage.runsettings'
          codeCoverageEnabled: true
          otherConsoleOptions: '/Logger:"trx;LogFileName=testResults.trx"'