Created
April 10, 2019 13:49
-
-
Save black-silence/35b958fe92c704de551a3ca4ea082b87 to your computer and use it in GitHub Desktop.
quick-dirty phpunit xml result patcher so sonarphp doesn't choke
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import xml.etree.ElementTree as ET | |
et = ET.parse('logfile.xml') | |
root = et.getroot() | |
for mastersuites in root: | |
for suite in mastersuites: | |
if not "file" in suite.attrib: | |
continue | |
filename = suite.attrib['file'] | |
for subsuite in suite: | |
if subsuite.tag != "testsuite": | |
continue | |
if not "file" in subsuite.attrib: | |
subsuite.attrib['file'] = filename | |
et.write('logfile.xml') |
Hello @kostajh,
I adapted this script slightly to move the testcase nodes into the parent suite instead. This fixed the Sonarqube Exception "Can not add the same measure twice" for me.
Maybe it helps in your case too. See https://gist.github.com/macghriogair/4976b8e6ea6d20a61cdeb95effb73364
(It is actually the same fix suggested already and implemented here: Codeception/Codeception#5004 (comment))
Thanks, worked for me with phpunit dataprovider ! :)
@macghriogair does this result in importing coverage for tests using data providers, or are coverage metrics for those tests just discarded?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With this gist, I get the following error with sonar-scanner:
The relevant part of the
junit.xml
file:where
testNewFromMenteeInvalidMentorList
is using a data provider.