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

Mixing inclusion and exclusion tags causes unexpected behaviour #498

Open
rtkaheller opened this issue Sep 9, 2015 · 1 comment
Open

Comments

@rtkaheller
Copy link

Feature file:
Feature: Lettuce tags

  @include_tag @exclude_tag
  Scenario: This test should be skipped
    Given a test
    Then this test is not run

  @include_tag
  Scenario: This test should be run
    Given a test
    Then this test is run
Python file:
from lettuce import step

@step('a test')
def a_test(step):
  pass

@step('this test is not run')
def not_run(step):
  assert False

@step('this test is run')
def run(step):
  assert True
Expected Result:

Running lettuce --tag=include_tag --tag=-exclude_tag will run only the second scenario


Feature: Lettuce tags                   # features/tags.feature:1
  @include_tag @exclude_tag             # features/tags.feature:3

  @include_tag
  Scenario: This test should be run# features/tags.feature:9
    Given a test                        # features/tags.py:4
    Then this test is run               # features/tags.py:12

1 feature (1 passed)
1 scenario (1 passed)
2 steps (2 passed)
Actual Result

Running lettuce --tag=include_tag --tag=-exclude_tag runs both scenarios


Feature: Lettuce tags                   # features/tags.feature:1
  @include_tag @exclude_tag             # features/tags.feature:3

  @include_tag @exclude_tag
  Scenario: This test should be skipped# features/tags.feature:4
    Given a test                        # features/tags.py:4
    Then this test is not run           # features/tags.py:8
    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lettuce/core.py", line 141, in __call__
        ret = self.function(self.step, *args, **kw)
      File "/home/rtkaheller/lettuce_tags/features/tags.py", line 9, in not_run
        assert False
    AssertionError

  @include_tag
  Scenario: This test should be run# features/tags.feature:9
    Given a test                        # features/tags.py:4
    Then this test is run               # features/tags.py:12

1 feature (0 passed)
2 scenarios (1 passed)
4 steps (1 failed, 3 passed)

This behaviour means there is no way to run all scenarios that match tag "a" but don't match tag "b".

@lawnmowerlatte
Copy link

I'd like to second this. I was hoping to use lettuce -t tag1 -t tag2 -t -wip so that my CI build won't run any in progress scenarios.

brarcher added a commit to brarcher/lettuce that referenced this issue Nov 22, 2016
If a user passes in a tag for which no scenario should run, e.g.
   --tag=-A

then the expectation is that no scenario with that tag would run.
However, the previous behavior was to a scenario with an inclusionary
tag regardless of the exclusionary tag. For example, if a scenario's
tags were:

   ['A', 'B]

and the user specified:

   --tag=-A --tag=B

the scenario would run.

This change changes the behavior of scenario filtering:
1) If an exclusionary tag matches the scenario is rejected.
2) If an inclusionary tag matches the scenario is accepted.
3) If a tag with ~ matches then it is accepted with some probability

gabrielfalcao#498
brarcher added a commit to brarcher/lettuce that referenced this issue Nov 22, 2016
If a user passes in a tag for which no scenario should run, e.g.

   --tag=-A

then the expectation is that no scenario with that tag would run.
However, the previous behavior was to a scenario with an inclusionary
tag regardless of the exclusionary tag. For example, if a scenario's
tags were:

   ['A', 'B]

and the user specified:

   --tag=-A --tag=B

the scenario would run.

This change changes the behavior of scenario filtering:
1) If there are inclusionary tags and none match, the
   scenario is rejected
2) If there are exclusionary tags and any match, the
   scenario is rejected
3) If there are ~ or ~- tags and none match, the scenario
   is rejected
4) If the above did not reject the scenario, it is accepted

gabrielfalcao#498
brarcher added a commit to brarcher/lettuce that referenced this issue Nov 22, 2016
If a user passes in a tag for which no scenario should run, e.g.

   --tag=-A

then the expectation is that no scenario with that tag would run.
However, the previous behavior was to include a scenario if an
inclusion tag matches regardless if an exclusion tag also matches.
scenario with an inclusionary. For example, if a scenario's
tags were:

   ['A', 'B']

and the user specified:

   --tag=-A --tag=B

the scenario would run.

This change changes the behavior of scenario filtering:
1) If there are inclusionary tags and none match, the
   scenario is rejected
2) If there are exclusionary tags and any match, the
   scenario is rejected
3) If there are ~ or ~- tags and none match, the scenario
   is rejected
4) If the above did not reject the scenario, it is accepted

gabrielfalcao#498
brarcher added a commit to brarcher/lettuce that referenced this issue Nov 22, 2016
If a user passes in a tag for which no scenario should run, e.g.

   --tag=-A

then the expectation is that no scenario with that tag would run.
However, the previous behavior was to include a scenario if an
inclusion tag matches regardless if an exclusion tag also matches.
scenario with an inclusionary. For example, if a scenario's
tags were:

   ['A', 'B']

and the user specified:

   --tag=-A --tag=B

the scenario would run.

This change changes the behavior of scenario filtering:
1) If there are inclusionary tags and none match, the
   scenario is rejected
2) If there are exclusionary tags and any match, the
   scenario is rejected
3) If there are ~ or ~- tags and none match, the scenario
   is rejected
4) If the above did not reject the scenario, it is accepted

gabrielfalcao#498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants