allure-framework / allure-python

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

Add support for allure decorators and allyre.dynamic functions to allure-pytest-bdd #726

Open delatrie opened 1 year ago

delatrie commented 1 year ago

Currently, only allure.attach and allure.attach.file functions are supported in allure-pytest-bdd. The following functions and decorators need to be supported as well:

sqandrew commented 1 year ago

Wow, what an amazing and long awaiting feature here!

Chrislu30604 commented 1 year ago

Hi, I have tried some workarounds to add tags or modify the description. It seems to work

In conftest.py:

import pytest
from allure_pytest_bdd.pytest_bdd_listener import PytestBDDListener
from allure_commons import plugin_manager
from allure_commons.model2 import Label
from allure_commons.types import LabelType

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()

    if report.when == "call":
        for plugin in plugin_manager.list_name_plugin():
            p = plugin[1]
            if isinstance(p, PytestBDDListener):
                test_result = p.lifecycle._get_item()
                # add tag to allure report
                for marker in item.iter_markers():
                    test_result.labels.append(
                        Label(name=LabelType.TAG, value=marker.name)
                    )
                # add epic to allure report
                test_result.labels.append(
                    Label(name=LabelType.EPIC, value="This is epic")
                )
                # modify allure report description
                test_result.description = "test description"
eyssonsaucedo commented 7 months ago

Hello @delatrie, now is posible use the list of decorators or not? my source is: @allure.title ("Test Authentication") @allure.description("This test attempts to log into the website using a login and a password. Fails if any error happens.\n\nNote that this test does not test 2-Factor Authentication.") @allure.tag("NewUI", "Essentials", "Authentication") @allure.severity(allure.severity_level.CRITICAL) @allure.label("owner", "John Doe") @allure.link("https://dev.example.com/", name="Website") @allure.issue("AUTH-123") @allure.testcase("TMS-456") @pytest.fixture(scope='function', autouse=True) def allure_logging(request: pytest.FixtureRequest): logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) stream = io.StringIO() handler = logging.StreamHandler(stream) logger.addHandler(handler)

But I can´t see in the Allure-report. Help me please.!!

fantom0005 commented 6 months ago

Hello @delatrie Could you tell us when this feature will be implemented? It's just very strange that allure-pytest-bdd is not compatible with Allure Test Ops.

fantom0005 commented 6 months ago

I created a pull request. https://github.com/allure-framework/allure-python/pull/818

It makes it possible to use basic allure decorators. But it only works in reporting.

@delatrie @skhomuti Could you please review it?