Skip to content

In tests use -m instead of -k for running tests by marker expressions #287

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

Merged
merged 2 commits into from
Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ scenario test, so we can use standard test selection:

.. code-block:: bash

py.test -k "backend and login and successful"
py.test -m "backend and login and successful"

The feature and scenario markers are not different from standard pytest markers, and the `@` symbol is stripped out
automatically to allow test selector expressions. If you want to have bdd-related tags to be distinguishable from the
Expand Down
15 changes: 4 additions & 11 deletions tests/feature/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ def test():

assert test.__scenario__.tags == set(['scenario_tag_1', 'scenario_tag_2'])
assert test.__scenario__.feature.tags == set(['feature_tag_1', 'feature_tag_2'])

assert getattr(test, 'scenario_tag_1')
assert getattr(test, 'scenario_tag_2')

assert getattr(test, 'feature_tag_1')
assert getattr(test, 'feature_tag_2')

test(request)


Expand Down Expand Up @@ -50,18 +43,18 @@ def i_have_bar():

scenarios('test.feature')
""")
result = testdir.runpytest('-k', 'scenario_tag_10 and not scenario_tag_01', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'scenario_tag_10 and not scenario_tag_01', '-vv').parseoutcomes()
assert result['passed'] == 1
assert result['deselected'] == 1

result = testdir.runpytest('-k', 'scenario_tag_01 and not scenario_tag_10', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'scenario_tag_01 and not scenario_tag_10', '-vv').parseoutcomes()
assert result['passed'] == 1
assert result['deselected'] == 1

result = testdir.runpytest('-k', 'feature_tag_1', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'feature_tag_1', '-vv').parseoutcomes()
assert result['passed'] == 2

result = testdir.runpytest('-k', 'feature_tag_10', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'feature_tag_10', '-vv').parseoutcomes()
assert result['deselected'] == 2


Expand Down