Code coverage stuck at 0%

SonarQube version 9.3
Azure Devops 2020 with SonarQube extension 5.6.1

The Sonarqube task can’t find the .trx and .coverage files produced during the Visual studio test task. It seems the vs test task keeps deleting the trx files after creating them. How should it be configured for Sonarqube to be able to find the files?

We have other project with similar configs that work just fine.

Thank you.

Sonarqube analysis logs

Attempting to locate a test results (.trx) file...
Looking for TRX files in: D:\_work\1675\TestResults
No test results files found
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in D:\_work\_temp
No coverage files found in the agent temp directory.
Coverage report conversion completed successfully.
The TFS Processor has finished

VS test task

steps:
- task: VSTest@2
  displayName: 'Assemblys de tests'
  inputs:
    testAssemblyVer2: |
     $(Build.BinariesDirectory)\$(Build.BuildNumber)\**\*test.dll
     
    searchFolder: '$(BUILD.BINARIESDIRECTORY)'
    runSettingsFile: CodeCoverage.runsettings
    runInParallel: false
    codeCoverageEnabled: true
    distributionBatchType: basedOnAssembly
    testRunTitle: 'DEV Tests Unitaires IC'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    diagnosticsEnabled: true
    rerunFailedTests: false

Sonarqube prepare task

steps:
- task: sonarsource.sonarqube..SonarQubePrepare@5
  displayName: 'Prepare analysis on SonarQube'
  inputs:
    SonarQube: 'SonarQube'
    projectKey: '****'
    projectName: '*****'
    extraProperties: |
     # Additional properties that will be passed to the scanner, 
     # Put one key=value per line, example:
     # sonar.exclusions=**/*.bin
     sonar.exclusions=Scripts/**, Content/**
     sonar.coverage.exclusions=Scripts/** , Content/**
     sonar.log.level=debug
     sonar.verbose=true

Do you have an example of how the VSTest task is configured for a project where you don’t face this issue?

It’s solved, it was a bad configuration in the .csproj of the test project.

Sorry about that.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.