GenericTestExecution does not work with maven multi-modules

This bug just consumed a lot of my nerves.

It also gets worse if you’re running on container-based CI infrastructure, because you cannot longer rely on static absolute paths during a pipeline run consisting of multiple jobs.

I’m running a CI setup where multiple tests (jest, cypress) are executed in different jobs, and a “final” sonarqube analysis job gathers all the test execution data. When the final job picks up the the test execution artifacts, the file paths no longer match the file paths in the final job container:

test execution file (produced by first job):

<testExecutions version="1">
  <file path="/builds/umwHayWZ0/myproject/mymodule/tests/unit/mytest.spec.js">
    <!-- .... -->
  </file>
</testExecutions>

log output of final sonarqube analysis job:

[INFO] Parsing /builds/jksdSajkfds0/myproject/mymodule/target/cypress-sonarqube-reporter/cypress-sonarqube-reports.all.xml
[INFO] Imported test execution data for 0 files
[INFO] Test execution data ignored for 21 unknown files, including:
/builds/umwHayWZ0/myproject/mymodule/tests/unit/mytest.spec.js
[....]

So the way I’m currently seeing it, sonar.testExecutionReportPaths is just completely broken.

BTW: Using SonarQube 8.9 LTS

The support for the module-level setting was removed in v7.6: [SONAR-11530] Change Generic coverage/test reports sensors to be global Sensors - SonarSource.

Even with module-level support, you wouldn’t be able to specify absolute paths produced by different jobs. The test execution data needs to be generated using relative paths to the root of the project.

GitHub - SonarSource/sonar-scanner-msbuild: SonarScanner for .NET still uses module-levels.

Is there some way to have a common config for different sort’s of modules? we have a maven build with a common parent pom, but not all modules build java applications. Some build nodejs packages. Those modules do not follow the conventions of the java build and the property sonar.testExecutionReportPaths cannot be the same.

Or is the general idea to configure both maven (junit) and nodes (jest) to write the same report file into the same location?

Hi @wemu,

According to the docs, sonar.testExecutionReportPaths accepts a

Comma-delimited list of paths to execution reports

So it would just be about configuring it with a full / correct list.

However, that parameter has little to do with JUnit and Jest tests.

Perhaps you should create a new thread with your full details.

 
Ann