pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.32k stars 221 forks source link

Pytest, @pytest.mark.skipif is not working. #508

Closed MrNeo28 closed 2 years ago

MrNeo28 commented 2 years ago

@pytest.mark.skipif is not working, I've read and tried this but it doesn't works for me.

Features code

Feature: As a new user

   I am displayed with welcome screen

    Scenario: verify navigation of the application to login 
        Given User is on Language_selection  screen
        Then User select language
        Then User click on "DONE" button

Code:

lang = 'nl'  # some language
@pytest.mark.skipif(lang == 'nl', reason='Language Selection not available')
@given(parsers.parse('User is on {Language_selection}  screen'))
def validate(driver, Language_selection):
    # current screen validation
    RegisterationPage(diver).validate(Language_selection)
    print('it worked')
youtux commented 2 years ago

The pytest.mark.skipif is supposed to be applied to test functions. Here you are applying to the implementation of a step. What behaviour would you expect? To skip all the tests that use this step, or that the step is not executed, but the rest of the steps are? I suggest you to instead write your own skip logic inside the step implementation.