allure-python icon indicating copy to clipboard operation
allure-python copied to clipboard

with `pytest-rerunfailures`, reruns are not recognized

Open sweh opened this issue 4 years ago • 4 comments

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): failed test (first run) Example Test second run via --reruns=5 (succeeded) succeeded test (second run) No flaky marker for test: no flaky marker

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 |

sweh avatar Jan 21 '21 08:01 sweh

Any work arounds on this?

aswinselva03 avatar Mar 26 '21 10:03 aswinselva03

Rerun is available in the Retries tabs, in suites and when you click on the test case that is failed

image

aswinselva03 avatar Apr 01 '21 09:04 aswinselva03

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')

igladun avatar Jun 23 '21 13:06 igladun

How removing json of failed tests is a workaround to deal with the fact that Allure is not able to deal with retries anymore ?

vduhautois avatar Dec 17 '21 13:12 vduhautois