I've been successfully using ActiveTagMatcher
to tag some tests that should be run under some conditions, but for some reason ActiveTagMatcher
is ignoring some of the values I set. I've boiled it down to this example:
features/test.feature
:
Feature: foo
# This does not work!
@only.with_variable_one=True
Scenario: variable one must be True
Then something
# This works fine.
@only.with_variable_two=foo
Scenario: variable two must be foo
Then something
# Try to see if shortening it to something that does not use the `=` works.
# It does not work either.
@only.with_variable_one
Scenario: variable two must be foo
Then something
features/environment.py
:
import os
from behave.tag_matcher import ActiveTagMatcher
def before_all(context):
condition = context.config.userdata.get("condition", None) is not None
values = {
"variable_one": condition,
"variable_two": "foo"
}
context.active_tag_matcher = ActiveTagMatcher(values)
def before_scenario(context, scenario):
if context.active_tag_matcher.should_exclude_with(scenario.effective_tags):
scenario.skip(reason="Disabled by an active tag")
return
I have a features/steps/something.py
which contains just enough to avoid complaints about the step being undefined:
@then(u"something")
def step_impl(context):
pass
Running behave
should only skip the 1st scenario only if I do not invoke it with -D condition
, but it always skips the 1st scenario! Conversely, it is never skipping the last scenario!
I'm using Behave 1.2.5.