allure-framework / allure-python

Allure integrations for Python test frameworks
https://allurereport.org/
Apache License 2.0
718 stars 237 forks source link

The error message only has the error message for the setup and no error message for the teardown in the overview of allure report #685

Closed python-zys closed 1 year ago

python-zys commented 2 years ago

code: `import pytest

@pytest.fixture(scope="function", autouse=True) def set_up(): print("Test set up start") raise Exception("set up failed") yield print("Test set up finish")

@pytest.fixture(scope="class", autouse=True) def tear_down(): print("Test tear down start") yield raise Exception("Tear down failed")

class TestAllure:

def test_allure(self):
    print("test start")
    assert 1 < 2
    print("test finish")`

Test result: image Allure display:

image

Expect result: The error message for the tear-down should display in the overview Environment: Pytest: 7.0.1 allure-pytest: 2.10.0

skhomuti commented 1 year ago

Hi @python-zys! You can stil see teardown error in the "Tear down" block if you expand it I'm not sure we should display both errors - the first error is displayed and mostly it's a main reason why test failed. And it's exactly what pytest gives from their hooks. More than, we can "merge" error messages and display they together and it will more or less ok, but merged error details will looks ugly a bit because error stack trace too long and complicated

delatrie commented 1 year ago

Both exceptions are included in the output (i.e., *-result.json). The first one is also included as the status details, so allure reporter puts it on the summary page of a test. All the exceptions are also reachable through their respective Set up, Test body and Tear down sections. This is an intended behavior, and this is something that the reporter expects from us: we only have place for one exception in statusDetails in the json file: one field for the message and one field for the trace. Merging exceptions somehow on a plugin level seems weird and too unclear to me.

If you feel the reporter should display exceptions differently, please, consider opening a feature request in allure2 repository.

I'm closing this issue without transferring, because the OP didn't respond for a long time. You can leave a comment here if it's still relevant to you though and I will either reopen or transfer it.