Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/behave/behave
Browse files Browse the repository at this point in the history
RELATED TO: #460, #459
  • Loading branch information
jenisys committed Jul 18, 2016
2 parents 8750253 + 0537bd8 commit 6f1b495
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ FORMATTERS:

* issue #462: json: Invalid JSON output when no features are selected (submitted by: remcowesterhoud)
* pull #423: sphinx.steps: Support ref link for each step (provided by: ZivThaller)
* pull #460: pretty: Print the step implementation location when dry-run (provided by: unklhe, jenisys)

CHANGES:

Expand Down
1 change: 1 addition & 0 deletions behave/formatter/ansi_escapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}

aliases = {
'untested': 'cyan', # SAME-COLOR AS: skipped
'undefined': 'yellow',
'pending': 'yellow',
'executing': 'grey',
Expand Down
12 changes: 10 additions & 2 deletions behave/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,18 @@ def run(self, runner):
step.status = "skipped"
if dry_run_scenario:
step.status = "untested"
found_step = runner.step_registry.find_match(step)
if not found_step:
found_step_match = runner.step_registry.find_match(step)
if not found_step_match:
step.status = "undefined"
runner.undefined_steps.append(step)
elif dry_run_scenario:
# -- BETTER DIAGNOSTICS: Provide step file location
# (when --format=pretty is used).
assert step.status == "untested"
for formatter in runner.formatters:
# -- EMULATE: Step.run() protocol w/o step execution.
formatter.match(found_step_match)
formatter.result(step)
else:
# -- SKIP STEPS: For disabled scenario.
# CASES:
Expand Down
37 changes: 28 additions & 9 deletions features/runner.dry_run.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,23 @@ Feature: Runner should support a --dry-run option
0 scenarios passed, 0 failed, 0 skipped, 4 untested
0 steps passed, 0 failed, 0 skipped, 0 undefined, 8 untested
"""
And the command output should contain
"""
Scenario: A1
"""
And the command output should contain:
"""
Feature: Alice
Scenario: A1
Scenario: A2
Scenario: A3
Scenario: A4
Scenario: A2
"""
And the command output should contain:
"""
Scenario: A3
"""
And the command output should contain:
"""
Scenario: A4
"""
And note that "all scenarios of this feature are contained"

Scenario: Dry-run one feature with tags should mark skipped scenario/steps as skipped
When I run "behave -f plain --dry-run --tags=@selected --no-skipped features/alice.feature"
Expand All @@ -112,11 +121,21 @@ Feature: Runner should support a --dry-run option
"""
And the command output should contain:
"""
Feature: Alice
Scenario: A1
Scenario: A3
Scenario: A4
Scenario: A1
"""
And the command output should contain:
"""
Scenario: A3
"""
And the command output should contain:
"""
Scenario: A4
"""
But the command output should not contain:
"""
Scenario: A2
"""
And note that "only tagged scenarios of this feature are contained (3 of 4)"


Scenario: Dry-run two features
Expand Down
62 changes: 42 additions & 20 deletions features/runner.select_scenarios_by_file_location.feature
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,10 @@ Feature: Select Scenarios by File Location
0 features passed, 0 failed, 0 skipped, 1 untested
0 scenarios passed, 0 failed, 0 skipped, 2 untested
"""
And the command output should contain:
"""
Feature: Alice
Scenario: Alice First
Scenario: Alice Last
"""
And the command output should contain "Scenario: Alice First"
And the command output should contain "Scenario: Alice Last"
But note that "all scenarios of this features are selected"
@file_location.select
@with.feature_configfile
Expand Down Expand Up @@ -246,17 +244,10 @@ Feature: Select Scenarios by File Location
0 features passed, 0 failed, 0 skipped, 1 untested
0 scenarios passed, 0 failed, 1 skipped, 3 untested
"""
And the command output should contain:
"""
Feature: Bob
Scenario: Setup Bob
Scenario: Bob in Berlin
Scenario: Teardown Bob
"""
But the command output should not contain:
"""
Scenario: Bob in Paris
"""
And the command output should contain "Scenario: Setup Bob"
And the command output should contain "Scenario: Bob in Berlin"
And the command output should contain "Scenario: Teardown Bob"
But the command output should not contain "Scenario: Bob in Paris"
@merge.file_locations
Scenario: Merge 2 adjacent file locations that refer to the same file
Expand All @@ -270,16 +261,22 @@ Feature: Select Scenarios by File Location
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Scenario: Alice Last
Then a step passes ... untested
"""
But the command output should not contain:
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Feature: Alice
Scenario: Alice Last
"""
And note that "both file locations are merged"
@merge.file_locations
@file_location.select_all
Expand All @@ -294,21 +291,30 @@ Feature: Select Scenarios by File Location
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Scenario: Alice Last
Then a step passes ... untested
"""
But the command output should not contain:
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Scenario: Alice Last
Then a step passes ... untested
"""
And note that "duplicated file locations are removed in the merge"
@merge.file_locations
@with.feature_configfile
Scenario: Merge 2 adjacent file locations to same file from features configfile
@with.feature_listfile
Scenario: Merge 2 adjacent file locations to same file from features-listfile
Given a file named "alice1_and_alice2.txt" with:
"""
# -- FEATURES CONFIGFILE:
Expand All @@ -326,19 +332,24 @@ Feature: Select Scenarios by File Location
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Scenario: Alice Last
Then a step passes ... untested
"""
But the command output should not contain:
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Feature: Alice
Scenario: Alice Last
Then a step passes ... untested
"""
@no_merge.file_locations
@with.feature_configfile
@with.feature_listfile
Scenario: No merge occurs if file locations to same file are not adjacent
Given a file named "alice1_bob2_and_alice2.txt" with:
"""
Expand All @@ -358,18 +369,29 @@ Feature: Select Scenarios by File Location
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Feature: Bob
Scenario: Setup Bob
Given a step passes ... untested
Scenario: Bob in Paris
Then a step passes ... untested
Scenario: Teardown Bob
Then a step passes ... untested
Feature: Alice
Scenario: Alice Last
Then a step passes ... untested
"""
But the command output should not contain:
"""
Feature: Alice
Scenario: Alice First
When a step passes ... untested
Scenario: Alice Last
Then a step passes ... untested
"""
And note that "non-adjacent file locations to the same file are not merged"
53 changes: 40 additions & 13 deletions features/runner.select_scenarios_by_name.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ Feature: Select named scenarios to run
And the command output should contain:
"""
Feature: Alice
Scenario: Alice in Wonderland
Scenario: Alice in Florida
Scenario: Alice in Antarctica
Scenario: Alice in Wonderland
Given a step passes ... untested
Scenario: Alice in Florida
When a step passes ... untested
Scenario: Alice in Antarctica
Then a step passes ... untested
Feature: Bob
Scenario: Alice and Bob
Scenario: Alice and Bob
Then a step passes ... untested
"""

Scenario: Select scenarios with name="Alice" and run them
Expand Down Expand Up @@ -102,9 +106,12 @@ Feature: Select named scenarios to run
And the command output should contain:
"""
Feature: Bob
Scenario: Bob in Berlin
Scenario: Bob in Florida
Scenario: Alice and Bob
Scenario: Bob in Berlin
Given a step passes ... untested
Scenario: Bob in Florida
When a step passes ... untested
Scenario: Alice and Bob
Then a step passes ... untested
"""

Scenario: Select scenarios with name="Florida"
Expand All @@ -118,10 +125,12 @@ Feature: Select named scenarios to run
And the command output should contain:
"""
Feature: Alice
Scenario: Alice in Florida
Scenario: Alice in Florida
When a step passes ... untested
Feature: Bob
Scenario: Bob in Florida
Scenario: Bob in Florida
When a step passes ... untested
"""

Scenario: Select scenarios with name that consists of multiple words
Expand Down Expand Up @@ -149,12 +158,17 @@ Feature: Select named scenarios to run
"""
Feature: Alice
Scenario: Alice in Wonderland
Given a step passes ... untested
Scenario: Alice in Florida
When a step passes ... untested
Scenario: Alice in Antarctica
Then a step passes ... untested
Feature: Bob
Scenario: Bob in Florida
When a step passes ... untested
Scenario: Alice and Bob
Then a step passes ... untested
"""

Scenario: Select scenarios by using a regular expression
Expand All @@ -168,8 +182,11 @@ Feature: Select named scenarios to run
"""
Feature: Alice
Scenario: Alice in Wonderland
Given a step passes ... untested
Scenario: Alice in Florida
When a step passes ... untested
Scenario: Alice in Antarctica
Then a step passes ... untested
"""
But the command output should not contain:
"""
Expand All @@ -187,12 +204,17 @@ Feature: Select named scenarios to run
"""
Feature: Alice
Scenario: Alice in Wonderland
Given a step passes ... untested
Scenario: Alice in Florida
When a step passes ... untested
Scenario: Alice in Antarctica
Then a step passes ... untested
Feature: Bob
Scenario: Bob in Berlin
Scenario: Bob in Florida
Scenario: Bob in Berlin
Given a step passes ... untested
Scenario: Bob in Florida
When a step passes ... untested
"""
But the command output should not contain:
"""
Expand All @@ -210,12 +232,17 @@ Feature: Select named scenarios to run
"""
Feature: Alice
Scenario: Alice in Wonderland
Given a step passes ... untested
Scenario: Alice in Florida
When a step passes ... untested
Scenario: Alice in Antarctica
Then a step passes ... untested
Feature: Bob
Scenario: Bob in Berlin
Scenario: Bob in Florida
Scenario: Bob in Berlin
Given a step passes ... untested
Scenario: Bob in Florida
When a step passes ... untested
"""
But the command output should not contain:
"""
Expand Down
3 changes: 3 additions & 0 deletions features/runner.select_scenarios_by_tag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ Feature: Select scenarios by using tags
"""
Feature: Alice
Scenario: Alice in Wonderland
Given a step passes ... untested
Scenario: Alice in Florida
When hotter step passes ... untested
Feature: Bob
Scenario: Bob in Florida
When freaky step passes ... untested
"""

0 comments on commit 6f1b495

Please sign in to comment.