Uploading Test Execution reports for dotnet test

Please provide

  • Operating system:
    Windows 11, or Linux Ubuntu
  • SonarLint plugin version: N/A
  • Programming language you’re coding in:
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version):

We are using SonarQube at my company.

We are running dotnet tool sonarscanner in gitlab CI on a linux server, and have successfully uploaded code and coverage data for a project. All is good there.

However, trouble starts when I try to upload test execution information.

I have chosen to only call dotnet build between sonarscanner begin and sonarscanner end steps, since we have already built and tested all the code (with coverage) in separate previous build steps in gitlab, and we have all the test and coverage result artifacts at hand to upload to sonar.

We have a single git repo containing both a C# backend and react.js frontend. We have code and tests from both, and we use cypress as well. So we have 3 sets of tests with coverage. (C# tests using xunit, Javascript tests using Jest, and Cypress tests).

Basically, this is what we are doing in the gitlab job:

    - dotnet sonarscanner begin /k:"$SONAR_PROJECT" /d:sonar.login="$SONAR_TOKEN" /d:sonar.host.url="$SONAR_HOST_URL"
    - dotnet build --configuration:$BUILD_CONFIGURATION src/$SOLUTIONNAME
    - dotnet sonarscanner end /d:sonar.login="$SONAR_TOKEN"

- We have no issues with reporting coverage information.
- Our c# test execution reports (*.trx) are uploaded just fine.
- My trouble is getting sonar to recognize and accept the test execution files I have given to sonar.sonar.testExecutionReportPaths for both Jest tests and Cypress tests.

When running both Jest and Cypress tests we are converting the test results into the sonar generic test execution format. i.e.

<testExecutions version="1">
  <file path="/builds/rocket/boost/src/WebsiteHost/ClientApp/src/components/Inputs/RadioGroup/Radio.spec.tsx">
    <testCase name="Radio throws when used outside of RadioGroup" duration="251" />

And uploading them to sonar using sonar.sonar.testExecutionReportPaths variable (as you can see from above).

The code in my sonarqube UI displays files with paths like this: builds/rocket/boost/src/WebsiteHost/ClientApp/src/components/Inputs/RadioGroup/Radio.spec.tsx

Now, my problem is that my build step is completed successfully, but my UI is still not displaying any unit tests. The count is -


Why are my unit tests not showing?
How can I tell if my test execution reports are being rejected or accepted and why?

Damn it, I had a typo in the variable name!
sonar.sonar.testExecutionReportPaths should be sonar.testExecutionReportPaths

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