allure-framework / allure-python

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

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

Open eskignax opened 5 years ago

eskignax commented 5 years ago

I'm submitting a ...

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
maxim-zaitsev commented 5 years ago

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...

sseliverstov commented 5 years ago

@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

eskignax commented 4 years ago

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 ).

harmin-parra commented 5 months ago

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 commented 5 months ago

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