Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
delatrie opened this issue Jan 20, 2023 · 5 comments
Labels
contribute Call for a contribution task:new feature Requesting new capability or software feature theme:pytest-bdd

Comments

@delatrie
Copy link
Contributor

delatrie commented Jan 20, 2023

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.title decorator
  • @allure.description decorator
  • @allure.description_html decorator
  • @allure.label decorator
  • @allure.severity decorator
  • @allure.epic decorator
  • @allure.feature decorator
  • @allure.story decorator
  • @allure.suite decorator
  • @allure.parent_suite decorator
  • @allure.sub_suite decorator
  • @allure.tag decorator
  • @allure.id decorator
  • @allure.manual decorator
  • @allure.link decorator
  • @allure.issue decorator
  • @allure.testcase decorator
  • allure.dynamic.title function
  • allure.dynamic.description function
  • allure.dynamic.description_html function
  • allure.dynamic.label function
  • allure.dynamic.severity function
  • allure.dynamic.epic function
  • allure.dynamic.feature function
  • allure.dynamic.story function
  • allure.dynamic.tag function
  • allure.dynamic.id function
  • allure.dynamic.link function
  • allure.dynamic.parameter function
  • allure.dynamic.issue function
  • allure.dynamic.testcase function
  • allure.dynamic.suite function
  • allure.dynamic.parent_suite function
  • allure.dynamic.sub_suite function
  • allure.dynamic.manual function
@sqandrew
Copy link

sqandrew commented Feb 1, 2023

Wow, what an amazing and long awaiting feature here!

@Chrislu30604
Copy link

Chrislu30604 commented Feb 3, 2023

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
Copy link

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
Copy link

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
Copy link

I created a pull request. #818

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

@delatrie @skhomuti Could you please review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribute Call for a contribution task:new feature Requesting new capability or software feature theme:pytest-bdd
Projects
None yet
Development

No branches or pull requests

5 participants