Skip to content

Instantly share code, notes, and snippets.

@black-silence
Created April 10, 2019 13:49
Show Gist options
  • Save black-silence/35b958fe92c704de551a3ca4ea082b87 to your computer and use it in GitHub Desktop.
Save black-silence/35b958fe92c704de551a3ca4ea082b87 to your computer and use it in GitHub Desktop.
quick-dirty phpunit xml result patcher so sonarphp doesn't choke
#!/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')
@Whax
Copy link

Whax commented Aug 24, 2019

Thanks, worked for me with phpunit dataprovider ! :)

@kostajh
Copy link

kostajh commented Aug 27, 2019

@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