Problems with test reports

Hi,
I am writing unit test using google test and generated xml file using mytest --gtest_output=xml:output.xml.
Now i want to load gtest generated xml report to sonarqube which is integrated with jenkins. I am facing issue in loading xml report and to display unit test results in dashboard.
I have used following sonar properties in groovy file
-Dsonar.tests=src/tests
-Dsonar.testExecutionReportPaths=/bin/**/tests/UnitTestCase.xml

i have tried even
-Dsonar.cxx.xunit.reportPath=/bin//tests/UnitTestCase.xml
and
-Dsonar.junit.reportPaths=/bin/
/tests/UnitTestCase.xml
But could not solve my issue.
Anyone please suggest me how can i proceed / how to convert gtest generated xml file to generic test execution format to make unit test display in sonarqube

Hi,

Welcome to the community!

I’ve moved your post to a new thread because the one you had added on to was 2 years old and had presumably been resting in peace before that.

What errors / results are you seeing?

 
Ann

Hi Ann,

I have shared error below from sonarqube logs

INFO: Parsing /home/jenkins/workspace/T_THINCLIENT/Skipper/skipper/bin//tests/TEST-UnitTestCase.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3.906s
INFO: Final Memory: 21M/74M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Error during parsing of generic test execution report '/home/jenkins/workspace/T_THINCLIENT/Skipper/skipper/bin/
/tests/TEST-UnitTestCase.xml’. Look at the SonarQube documentation to know the expected XML format.
ERROR: Caused by: /home/jenkins/workspace/T_THINCLIENT/Skipper/skipper/bin/**/tests/TEST-UnitTestCase.xml (No such file or directory)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
script returned exit code 2

Sonarqube is not able to pick the unit test xml which is generated from googletest framework.
Can u suggest me how to convert gtest xml to generic xml report format.

Hi @ganncamp, @Anitha ,
I am also facing the same issue . I am using Jest framework for unit testing.
How did u fix the issue? Please suggest me on this.TIA
below are logs and sonar.properties

[Test/Sonar] INFO: Parsing /reports/test-reporter.xml
[Test/Sonar] INFO: ------------------------------------------------------------------------
[Test/Sonar] INFO: EXECUTION FAILURE
[Test/Sonar] INFO: ------------------------------------------------------------------------
[Test/Sonar] INFO: Total time: 23.444s
[Test/Sonar] INFO: Final Memory: 31M/117M
[Test/Sonar] INFO: ------------------------------------------------------------------------
[Test/Sonar] ERROR: Error during SonarQube Scanner execution
[Test/Sonar] ERROR: Error during parsing of generic test execution report ‘/reports/test-reporter.xml’. Look at the SonarQube documentation to know the expected XML format.
[Test/Sonar] ERROR: Caused by: Line 3 of report refers to a file which is not configured as a test file: /src/test/Users.spec.js
[Test/Sonar] ERROR:
[Test/Sonar] ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[Pipeline] [Test/Sonar] }
[Test/Sonar] WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeeded?

sonar.sources=./src
sonar.tests=./src/__test__

sonar.test.inclusions=./src/__test__/*.spec.js
sonar.coverage.exclusions=./src/__test__/__snapshots__/**
sonar.exclusions=./src/assets/*,./node_modules/*,./src/__test__/*

sonar.javascript.junit.reportPaths=./junit.xml
sonar.javascript.lcov.reportPaths=./output/coverage/jest/lcov.info
sonar.testExecutionReportPaths=./reports/test-reporter.xml

Hi,

What about the error message you’re getting is unclear?

 
Ann

Hi pushpa,
I have used xslt stylesheet to convert googletest generated xml to sonarqube supported xml format. That fixed my issue.

Hi @ganncamp,
I have included these file in sonar.properties file( sonar.test.inclusions=./src/test/*.spec.js )
and the test-reporter.xml format also correct…
Pls share your input on these errors. TIA

Hi,

What have you configured for sonar.tests? It’s the analog to sonar.sources, but for tests. These docs should help you understand the relationship.

 
HTH,
Ann

Could you share with us the xslt you have used?

1 Like

could you share xslt stylesheet

if you are using jhipster please try this command:

./mvnw -Pprod clean verify sonar:sonar -Dsonar.host.url=http://localhost:9001

this is the related url link:

Hi Anitha can you please share this xslt