mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 22:43:41 +00:00
Fix BIMTester file overwrite bug and template re-reading.
This commit is contained in:
@@ -11,36 +11,37 @@ import sys
|
|||||||
def run_tests():
|
def run_tests():
|
||||||
behave_main(['features', '--junit', '--junit-directory', 'junit/'])
|
behave_main(['features', '--junit', '--junit-directory', 'junit/'])
|
||||||
print('# All tests have finished. Generating HTML reports now.')
|
print('# All tests have finished. Generating HTML reports now.')
|
||||||
with open('features/template.html') as template:
|
if not os.path.exists('report'):
|
||||||
os.mkdir('report')
|
os.mkdir('report')
|
||||||
for file in os.listdir('junit/'):
|
for file in os.listdir('junit/'):
|
||||||
if not file.endswith('.xml'):
|
if not file.endswith('.xml'):
|
||||||
continue
|
continue
|
||||||
root = ET.parse('junit/{}'.format(file)).getroot()
|
root = ET.parse('junit/{}'.format(file)).getroot()
|
||||||
data = {
|
data = {
|
||||||
'report_name': root.get('name'),
|
'report_name': root.get('name'),
|
||||||
'testcases': []
|
'testcases': []
|
||||||
}
|
}
|
||||||
for testcase in root.findall('testcase'):
|
for testcase in root.findall('testcase'):
|
||||||
steps = []
|
steps = []
|
||||||
system_out = testcase.findall('system-out')[0].text.splitlines()
|
system_out = testcase.findall('system-out')[0].text.splitlines()
|
||||||
for line in system_out:
|
for line in system_out:
|
||||||
if line.strip()[0:5] in ['Given', 'Then ', 'When ']:
|
if line.strip()[0:5] in ['Given', 'Then ', 'When ']:
|
||||||
is_success = True if ' ... passed in ' in line else False
|
is_success = True if ' ... passed in ' in line else False
|
||||||
steps.append({
|
steps.append({
|
||||||
'name': line.strip().split(' ... ')[0],
|
'name': line.strip().split(' ... ')[0],
|
||||||
'time': line.strip().split(' ... ')[1],
|
'time': line.strip().split(' ... ')[1],
|
||||||
'is_success': is_success
|
'is_success': is_success
|
||||||
})
|
})
|
||||||
data['testcases'].append({
|
data['testcases'].append({
|
||||||
'name': testcase.get('name'),
|
'name': testcase.get('name'),
|
||||||
'is_success': testcase.get('status') == 'passed',
|
'is_success': testcase.get('status') == 'passed',
|
||||||
'time': testcase.get('time'),
|
'time': testcase.get('time'),
|
||||||
'steps': steps,
|
'steps': steps,
|
||||||
'total_passes': len([s for s in steps if s['is_success'] == True]),
|
'total_passes': len([s for s in steps if s['is_success'] == True]),
|
||||||
'total_steps': len(steps)
|
'total_steps': len(steps)
|
||||||
})
|
})
|
||||||
with open('report/{}.html'.format(file[0:-4]), 'w') as out:
|
with open('report/{}.html'.format(file[0:-4]), 'w') as out:
|
||||||
|
with open('features/template.html') as template:
|
||||||
out.write(pystache.render(template.read(), data))
|
out.write(pystache.render(template.read(), data))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user