Can't show count of unit tests

  • which versions are you using: SonarQube Community Edition Version 9.9.4 (build 87374)
  • how is SonarQube deployed: Github actions
  • what are you trying to achieve: show count of unit tests and e2e tests - is it possible to show the count of e2e tests? is it possible to show the count of cucumber tests?
  • what have you tried so far to achieve this:
    My yml step is:
      - name: SonarQube Scan
          SONAR_PROJECT_KEY: ${{ secrets.sonar_projectkey }}
          SONAR_TOKEN: ${{ secrets.sonar_token }}
          SONAR_HOST_URL: ${{ secrets.sonar_host_url }}
        run: |
          sonar-scanner \
          -Dsonar.projectKey=$SONAR_PROJECT_KEY \
          -Dsonar.sources=. \
          -Dsonar.tests=src/app,cucumber/step-definitions,playwright/tests \
          -Dsonar.exclusions="**/main.ts,**/docker/**,**/babel.config.js,**/commitlint.config.js,**/jest-cucumber.config.js,**/jest.config.js,**/playwright.config.ts,**/setup-jest.ts,**/*.scss,playwright/pages/**,**/**/*routes.ts,**/**/*config.ts,**/*.config.ts,**/*.config.js" \
          -Dsonar.test.exclusions="playwright/pages,playwright/results" \
          -Dsonar.javascript.lcov.reportPaths=coverage/ \

Logs say:
INFO: Parsing /home/runner/actions-runner/_work/…/coverage/unit-tests/sonar-report.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 1 unknown files, including:

xml file:

<testExecutions version="1">
<file path="src/app/app.component.spec.ts">
<testCase name="AppComponent should have as title &apos;...&apos;" duration="36" />
<testCase name="AppComponent should create the app" duration="9" />
<testCase name="AppComponent should allow change of status" duration="9" />


Welcome to the community!

These aren’t available as separate numbers; only in aggregate.

I believe this means that src/app/app.component.spec.ts isn’t recognized as a test file. Why would that be?

First you say everything in the project, recursive, is a source file:

Then you define a subset of files as tests:

Without, as far as I can tell, excluding your tests from the source set:

To be honest, I don’t understand why your analysis isn’t failing with an error about sources and tests not being disjoint sets.

Can you share your full analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.