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

--allure-link-pattern option don't filter any test.

Open eskignax opened this issue 5 years ago • 5 comments

I'm submitting a ...

  • [ X ] bug report
  • [ ] feature request
  • [ ] support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

--allure-link-pattern option don't filter any test, and run the full suite.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

import allure

@allure.testcase('https://redmine.xxx.com/issues/25','25')
def test_with_allure_link():
    pass

def test_without_allure_link():
    pass
(venv) bash-5.0$ python3 -m pytest --allure-link-pattern='testcase:https://redmine.xxx.com/issues/25'
======================================================================================= test session starts ========================================================================================
platform linux -- Python 3.7.4, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
rootdir: /home/xxx/PycharmProjects/sandbox/bugs
plugins: allure-pytest-2.7.0
collected 2 items                                                                                                                                                                                  

test_allure_link.py ..                                                                                                                                                                       [100%]

===================================================================================== 2 passed in 0.02 seconds =====================================================================================

What is the expected behavior?

--allure-link-pattern should only run the test with the matching link decorator.

Please tell us about your environment:

Other information

python3 -m pytest --allure-link-pattern='testcase:https://redmine.xxx.com/issues/25'
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: /server/xxx, inifile: pytest.ini, testpaths: features/tests
plugins: allure-pytest-2.8.4
collected 2772 items / 2 deselected / 2770 selected

eskignax avatar Oct 01 '19 08:10 eskignax

Really?

pytest --help

...
--allure-link-pattern=LINK_TYPE:LINK_PATTERN
                        Url pattern for link type. Allows short links in test,
                        like 'issue-1'. Text will be formatted to full url
                        with python str.format().
...

So this parameter does not filter tests, it's for short testcase link in the report

By the way I'm also looking for a way to run tests based on allure testcase link...

maxim-zaitsev avatar Oct 16 '19 08:10 maxim-zaitsev

@maxim-zaitsev links are marks too: https://github.com/allure-framework/allure-python/blob/master/allure-pytest/src/helper.py#L36, so you can implement filtering with pytest hook pytest_collection_modifyitems. Something like this https://github.com/allure-framework/allure-python/blob/master/allure-pytest/src/plugin.py#L142

sseliverstov avatar Oct 16 '19 09:10 sseliverstov

I use this in my code to make it possible to trigger test by test case id from the allure test case link : https://docs.pytest.org/en/stable/example/markers.html#custom-marker-and-command-line-option-to-control-test-runs.

But would be nice to have this feature in the allure-python package directly (since you already have it for Epic ).

eskignax avatar Jun 25 '20 02:06 eskignax

This works for me

pytest --allure-link-pattern tms:https://example.com/{}

@allure.testcase("TEST-456")
def test_blah_blah():
   pass

Replace --allure-link-pattern='testcase:https://redmine.xxx.com/issues/25 by --allure-link-pattern='tms:https://redmine.xxx.com/issues/{}

harmin-parra avatar Jun 17 '24 18:06 harmin-parra

I opened #786 to suggest renaming testcase pattern name by tms

harmin-parra avatar Jun 17 '24 18:06 harmin-parra