Skip to content

Instantly share code, notes, and snippets.

@ryanwilsonperkin
Created March 5, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanwilsonperkin/ea158f5d967cd55b06d7f88be41e0e2c to your computer and use it in GitHub Desktop.
Save ryanwilsonperkin/ea158f5d967cd55b06d7f88be41e0e2c to your computer and use it in GitHub Desktop.
Reads Xunit XML files and prints the (sorted) test names to stdout.
#!/usr/local/bin/python
"""
Reads Xunit XML files and prints the (sorted) test names to stdout.
usage: python create_test_list.py file [file...]
"""
import sys
import xml.etree.ElementTree as ET
def xmlToList(filename):
tree = ET.parse(filename)
root = tree.getroot()
return [
'{classname}:{name}'.format(**child.attrib)
for child in root
]
if __name__ == "__main__":
filenames = sys.argv[1:]
test_list = []
for filename in filenames:
test_list.extend(xmlToList(filename))
test_list.sort()
for test in test_list:
sys.stdout.write(test + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment