allure-python
allure-python copied to clipboard
Add support for allure decorators and allyre.dynamic functions to allure-pytest-bdd
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:
@allure.titledecorator@allure.descriptiondecorator@allure.description_htmldecorator@allure.labeldecorator@allure.severitydecorator@allure.epicdecorator@allure.featuredecorator@allure.storydecorator@allure.suitedecorator@allure.parent_suitedecorator@allure.sub_suitedecorator@allure.tagdecorator@allure.iddecorator@allure.manualdecorator@allure.linkdecorator@allure.issuedecorator@allure.testcasedecoratorallure.dynamic.titlefunctionallure.dynamic.descriptionfunctionallure.dynamic.description_htmlfunctionallure.dynamic.labelfunctionallure.dynamic.severityfunctionallure.dynamic.epicfunctionallure.dynamic.featurefunctionallure.dynamic.storyfunctionallure.dynamic.tagfunctionallure.dynamic.idfunctionallure.dynamic.linkfunctionallure.dynamic.parameterfunctionallure.dynamic.issuefunctionallure.dynamic.testcasefunctionallure.dynamic.suitefunctionallure.dynamic.parent_suitefunctionallure.dynamic.sub_suitefunctionallure.dynamic.manualfunction
Wow, what an amazing and long awaiting feature here!
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"
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.!!
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.
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?