Error:
When analyzing a project in a pipeline the SonarQube analysis fails when there are no unit tests:
21:19:22 > Error during parsing of generic test execution report 'D:\agent\workspace\cd\nexus-webportlet\nxs-ggz-epd-clienttoestemmingen-portlet\master\reports\sonar\test-results.xml'. Look at the SonarQube documentation to know the expected XML format.
Our configuration:
sonarqube{
properties{
property 'sonar.projectKey', rootProject.name
property 'sonar.projectName', "$group/${rootProject.name}"
property 'sonar.projectVersion', baseVersion
property 'sonar.sources', 'e2e,src'
property 'sonar.exclusions', '**/node_modules/**,**/*.spec.ts'
property 'sonar.tests', 'e2e,src'
property 'sonar.test.inclusions', '**/*.spec.ts'
property 'sonar.testExecutionReportPaths', 'reports/sonar/test-results.xml'
property 'sonar.javascript.lcov.reportPaths', 'reports/coverage/lcov.info'
property 'sonar.typescript.lcov.reportPaths', 'reports/coverage/lcov.info'
}
}
I know I shouldn’t use sonar.testExecutionReportPaths
but sonar.testExecutionReportPaths
instead. But this is unrelated to this problem because with other projects it still works (for now of course).
I would expect the plugin doesn’t fail on a missing XML, but instead takes for granted that there are no tests. This is the behaviour I see with the (unrelated) xUnit plugin:
21:19:11 INFO: [JUnit] - No test report file(s) were found with the pattern 'reports/test/test-results.xml' relative to 'd:\agent\workspace\cd\nexus-webportlet\nxs-ggz-epd-clienttoestemmingen-portlet\master' for the testing framework 'JUnit'. Did you enter a pattern relative to (and within) the workspace directory? Did you generate the result report(s) for 'JUnit'?
21:19:11 WARNING: No test reports found for the metric 'JUnit' with the resolved pattern 'reports/test/test-results.xml'.
21:19:11 INFO: Skipping the metric tool processing.
21:19:11 INFO: There are errors when processing test results.
21:19:11 INFO: Skipping tests recording.
Work-around:
Add a single test .
Versions:
- SonarQube 6.7.1
- SonarQube Gradle Plugin 2.6.2
- SonarQube Scanner for Jenkins 2.7.1
- Jenkins 2.121.2
- Gradle 3.4.1