allure-python
allure-python copied to clipboard
with `pytest-rerunfailures`, reruns are not recognized
Describe the bug Running a Pytest Test-Suite with the pytest-rerunfailures plugin does not recognize reruns. Instead, the result of the last run test is shown. Previously failed tests can be found as duplicates in the timeline. The flaky marker is not applied.
Expected behavior The result of the last run test is shown. A flaky marker is applied. I am able to filter for tests that were rerun.
Screenshots
Example Test first run (failed):
Example Test second run via --reruns=5 (succeeded)
No flaky marker for test:
Environment (please complete the following information):
| Allure version | 2.13.6 | | Python | 3.6.12 | | Test framework | [email protected] | | Allure adaptor | [email protected], [email protected] | | Generate report using | https://github.com/simple-elf/allure-report-action |
Any work arounds on this?
Rerun is available in the Retries tabs, in suites and when you click on the test case that is failed
As a workaround, to remove the .json files with failed tests, if tests passed. (Script was created in few minutes 😄 )
import glob
import json
import os
path = f'reports{os.sep}allure'
test_files = glob.glob(f'{path}{os.sep}*-result.json')
all_tests = []
for test_path in test_files:
# adding path + content
with open(test_path) as f:
all_tests.append([test_path, f.read()])
to_del = []
for x in all_tests:
for y in all_tests:
if x[0] == y[0]:
continue
json_x1 = json.loads(x[1])
json_y1 = json.loads(y[1])
if json_x1['name'] == json_y1['name']:
if json_x1['status'] == 'passed' and json_y1['status'] == 'failed':
to_del.append(y)
for t in to_del:
if os.path.exists(t[0]):
os.remove(t[0])
print(f'Deleted file {t[0]}')
else:
print('File already deleted')
How removing json of failed tests is a workaround to deal with the fact that Allure is not able to deal with retries anymore ?