-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathrerun_failed_tests.py
More file actions
25 lines (22 loc) · 857 Bytes
/
rerun_failed_tests.py
File metadata and controls
25 lines (22 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import xml.etree.ElementTree as ET
import subprocess
def parse_test_results(file_path):
tree = ET.parse(file_path)
root = tree.getroot()
failed_tests = []
for testcase in root.iter('testcase'):
if testcase.find('failure') is not None:
failed_tests.append(testcase.get('name'))
return failed_tests
def rerun_failed_tests(failed_tests):
if failed_tests:
print("Initial failed tests:", failed_tests)
failed_test_names = ' '.join(failed_tests)
result = subprocess.run(f'pytest --headless {failed_test_names}', shell=True, capture_output=True, text=True)
print(result.stdout)
print(result.stderr)
else:
print('All tests passed.')
if __name__ == "__main__":
failed_tests = parse_test_results('test-reports/junit_intg.xml')
rerun_failed_tests(failed_tests)