Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xUnit sensor couldn't parse test report with 0 testsuite tag #1595

Closed
silmerusse opened this issue Nov 20, 2018 · 3 comments · Fixed by #1599
Closed

xUnit sensor couldn't parse test report with 0 testsuite tag #1595

silmerusse opened this issue Nov 20, 2018 · 3 comments · Fixed by #1599
Assignees
Labels
Milestone

Comments

@silmerusse
Copy link

Description

When an xUnit test report does not have any testsuite tag, xUnit sensor throws exception and could not continue to parse other reports.

Steps to reproduce the problem

Analyze a test report as follows:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="0" failures="0" disabled="0" errors="0" timestamp="2018-11-20T11:37:41" time="0" name="AllTests">
</testsuites>

The test program contains no actual tests but it serves as a stub for future development.
This report was created by gtest with option --gtest_output=xml:test_report.xml

Expected behavior

Expect the report should be parsed without error.

Actual behavior

xUnit sensor throws exception and could not continue to parse other reports.

Known workarounds

Perhaps adding a null check at cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/XunitReportParser.java:61 may fix this problem but I haven't verified it yet.

do {
  parseTestSuiteTag(testSuiteCursor);
} while (testSuiteCursor.getNext() != null);

LOG file

11:37:56.061 INFO: Scanner found '3' report files
11:37:56.061 INFO: Parser will parse '3' report files
11:37:56.075 INFO: Processing report '/var/jenkins_home/workspace/playground-build-test-scan/report/blank_test_report.xml'
11:37:56.075 DEBUG: Transformation skipped: no xslt given
11:37:56.110 ERROR: Cannot feed the data into SonarQube, details: 'javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,1]
Message: Can not call 'getAttributeValue(): cursor does not point to a valid node (curr event [null]; cursor state CLOSED)'
11:37:56.111 INFO: Sensor C++ (Community) XunitSensor [cxx] (done) | time=79ms

Related information

  • cxx plugin version? 1.1.0
  • SonarQube version? 7.4
@guwirth guwirth added the bug label Nov 20, 2018
@guwirth guwirth added this to the 1.2.1 milestone Nov 20, 2018
@guwirth
Copy link
Collaborator

guwirth commented Nov 20, 2018

@silmerusse thx for reporting this issue.

@guwirth
Copy link
Collaborator

guwirth commented Nov 26, 2018

@silmerusse fixed you can try with 1.2.1 snapshot (you can download it from starting page).

@silmerusse
Copy link
Author

@guwirth I tried the new version and confirm it's fixed. Thank you.

@guwirth guwirth mentioned this issue Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants