Skip to content

Commit

Permalink
Do not test for of use empty scenarios in the specs/features.
Browse files Browse the repository at this point in the history
  • Loading branch information
brasmusson committed Aug 6, 2017
1 parent 44c61da commit 10f0951
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 162 deletions.
6 changes: 4 additions & 2 deletions features/docs/cli/execute_with_tag_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Feature: Tag logic
@ignore
Scenario: And yet another Example
Given passing
"""

Scenario: ANDing tags
Expand Down Expand Up @@ -78,9 +79,10 @@ Feature: Tag logic
@ignore
Scenario: And yet another Example
Given passing
2 scenarios (1 undefined, 1 passed)
1 step (1 undefined)
2 scenarios (2 undefined)
2 steps (2 undefined)
"""

Scenario: Run with limited tag count, blowing it on scenario
Expand Down
6 changes: 2 additions & 4 deletions features/docs/gherkin/outlines.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ Feature: Scenario outlines
"""
Feature: Outline Sample
Scenario: I have no steps
Scenario Outline: Test state
Given <state> without a table
Given <other_state> without a table
Expand All @@ -73,7 +71,7 @@ Feature: Scenario outlines
Failing Scenarios:
cucumber features/outline_sample.feature:12
5 scenarios (1 failed, 1 undefined, 3 passed)
4 scenarios (1 failed, 1 undefined, 2 passed)
8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
"""

Expand Down Expand Up @@ -154,7 +152,7 @@ Feature: Scenario outlines
Failing Scenarios:
cucumber features/outline_sample.feature:12
5 scenarios (1 failed, 1 undefined, 3 passed)
4 scenarios (1 failed, 1 undefined, 2 passed)
8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
"""
77 changes: 26 additions & 51 deletions spec/cucumber/formatter/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,6 @@ module Formatter
run_defined_feature
end

describe 'with a scenario with no steps' do
define_feature <<-FEATURE
Feature: Banana party
Scenario: Monkey eats bananas
FEATURE

it 'outputs the json data' do
expect(load_normalised_json(@out)).to eq MultiJson.load(%{
[{"id": "banana-party",
"uri": "spec.feature",
"keyword": "Feature",
"name": "Banana party",
"line": 1,
"description": "",
"elements":
[{"id": "banana-party;monkey-eats-bananas",
"keyword": "Scenario",
"name": "Monkey eats bananas",
"line": 3,
"description": "",
"type": "scenario"}]}]})
end
end

describe 'with a scenario with an undefined step' do
define_feature <<-FEATURE
Feature: Banana party
Expand Down Expand Up @@ -106,7 +81,7 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 4,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:87"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:62"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -143,9 +118,9 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 4,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:124"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:99"},
"result": {"status": "failed",
"error_message": "no bananas (RuntimeError)\\n./spec/cucumber/formatter/json_spec.rb:124:in `/^there are bananas$/'\\nspec.feature:4:in `Given there are bananas'",
"error_message": "no bananas (RuntimeError)\\n./spec/cucumber/formatter/json_spec.rb:99:in `/^there are bananas$/'\\nspec.feature:4:in `Given there are bananas'",
"duration": 1}}]}]}]})
end
end
Expand Down Expand Up @@ -181,9 +156,9 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 4,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:162"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:137"},
"result": {"status": "pending",
"error_message": "TODO (Cucumber::Pending)\\n./spec/cucumber/formatter/json_spec.rb:162:in `/^there are bananas$/'\\nspec.feature:4:in `Given there are bananas'",
"error_message": "TODO (Cucumber::Pending)\\n./spec/cucumber/formatter/json_spec.rb:137:in `/^there are bananas$/'\\nspec.feature:4:in `Given there are bananas'",
"duration": 1}}]}]}]})
end
end
Expand Down Expand Up @@ -223,7 +198,7 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 8,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:204"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:179"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -277,7 +252,7 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 6,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:252"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:227"},
"result": {"status": "passed",
"duration": 1}}]},
{"id": "banana-party;monkey-eats-bananas;fruit-table;2",
Expand All @@ -296,7 +271,7 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 15,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:252"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:227"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -355,7 +330,7 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 6,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:332"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:307"},
"result": {"status": "passed",
"duration": 1}}]},
{"id": "banana-party;monkey-eats-bananas",
Expand All @@ -372,7 +347,7 @@ module Formatter
"line": 11,
"comments": [{"value": "#step comment1",
"line": 10}],
"match": {"location": "spec/cucumber/formatter/json_spec.rb:333"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:308"},
"result": {"status": "passed",
"duration": 1}}]},
{"keyword": "Background",
Expand All @@ -386,7 +361,7 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 6,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:332"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:307"},
"result": {"status": "passed",
"duration": 1}}]},
{"id": "banana-party;monkey-eats-bananas;fruit-table;2",
Expand All @@ -407,7 +382,7 @@ module Formatter
"line": 22,
"comments": [{"value": "#step comment2",
"line": 15}],
"match": {"location": "spec/cucumber/formatter/json_spec.rb:333"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:308"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -450,7 +425,7 @@ module Formatter
"doc_string": {"value": "the doc string",
"content_type": "",
"line": 5},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:428"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:403"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -488,7 +463,7 @@ module Formatter
"name": "there are bananas",
"line": 4,
"output": ["from step"],
"match": {"location": "spec/cucumber/formatter/json_spec.rb:468"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:443"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -600,7 +575,7 @@ module Formatter
"line": 4,
"embeddings": [{"mime_type": "mime-type",
"data": "YWJj"}],
"match": {"location": "spec/cucumber/formatter/json_spec.rb:578"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:553"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -645,7 +620,7 @@ module Formatter
"line": 4,
"embeddings": [{"mime_type": "image/png",
"data": "Zm9v"}],
"match": {"location": "spec/cucumber/formatter/json_spec.rb:618"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:593"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -686,31 +661,31 @@ module Formatter
"description": "",
"type": "scenario",
"before":
[{"match": {"location": "spec/cucumber/formatter/json_spec.rb:663"},
[{"match": {"location": "spec/cucumber/formatter/json_spec.rb:638"},
"result": {"status": "passed",
"duration": 1}},
{"match": {"location": "spec/cucumber/formatter/json_spec.rb:664"},
{"match": {"location": "spec/cucumber/formatter/json_spec.rb:639"},
"result": {"status": "passed",
"duration": 1}}],
"steps":
[{"keyword": "Given ",
"name": "there are bananas",
"line": 4,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:670"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:645"},
"result": {"status": "passed",
"duration": 1},
"after":
[{"match": {"location": "spec/cucumber/formatter/json_spec.rb:667"},
[{"match": {"location": "spec/cucumber/formatter/json_spec.rb:642"},
"result": {"status": "passed",
"duration": 1}},
{"match": {"location": "spec/cucumber/formatter/json_spec.rb:668"},
{"match": {"location": "spec/cucumber/formatter/json_spec.rb:643"},
"result": {"status": "passed",
"duration": 1}}]}],
"after":
[{"match": {"location": "spec/cucumber/formatter/json_spec.rb:666"},
[{"match": {"location": "spec/cucumber/formatter/json_spec.rb:641"},
"result": {"status": "passed",
"duration": 1}},
{"match": {"location": "spec/cucumber/formatter/json_spec.rb:665"},
{"match": {"location": "spec/cucumber/formatter/json_spec.rb:640"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down Expand Up @@ -748,13 +723,13 @@ module Formatter
[{"keyword": "Given ",
"name": "there are bananas",
"line": 4,
"match": {"location": "spec/cucumber/formatter/json_spec.rb:729"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:704"},
"result": {"status": "passed",
"duration": 1}}],
"around":
[{"match": {"location": "unknown_hook_location:1"},
"result": {"status": "failed",
"error_message": "error (RuntimeError)\\n./spec/cucumber/formatter/json_spec.rb:728:in `Around'",
"error_message": "error (RuntimeError)\\n./spec/cucumber/formatter/json_spec.rb:703:in `Around'",
"duration": 1}}]}]}]})
end
end
Expand Down Expand Up @@ -795,7 +770,7 @@ module Formatter
"rows":
[{"cells": ["aa", "bb"]},
{"cells": ["cc", "dd"]}],
"match": {"location": "spec/cucumber/formatter/json_spec.rb:773"},
"match": {"location": "spec/cucumber/formatter/json_spec.rb:748"},
"result": {"status": "passed",
"duration": 1}}]}]}]})
end
Expand Down
93 changes: 1 addition & 92 deletions spec/cucumber/formatter/legacy_api/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,66 +151,6 @@ def after_hooks(source)
]
end

it 'a scenario with no steps' do
execute_gherkin do
feature do
scenario
end
end

expect( formatter.legacy_messages ).to eq [
:before_features,
:before_feature,
:before_tags,
:after_tags,
:feature_name,
:before_feature_element,
:before_tags,
:after_tags,
:scenario_name,
:after_feature_element,
:after_feature,
:after_features
]
end

it 'a scenario with no steps coming after another scenario' do
execute_gherkin do
feature do
scenario do
step 'passing'
end
scenario
end
end
expect( formatter.legacy_messages ).to eq [
:before_features,
:before_feature,
:before_tags,
:after_tags,
:feature_name,
:before_feature_element,
:before_tags,
:after_tags,
:scenario_name,
:before_steps,
:before_step,
:before_step_result,
:step_name,
:after_step_result,
:after_step,
:after_steps,
:after_feature_element,
:before_feature_element,
:before_tags,
:after_tags,
:scenario_name,
:after_feature_element,
:after_feature,
:after_features
]
end

it 'a scenario with one step' do
execute_gherkin do
feature do
Expand Down Expand Up @@ -1953,38 +1893,6 @@ def apply_after_hooks(test_case)
end
end

context 'with an exception in an after hook but no steps' do
it 'prints the exception after the scenario name' do
filters = [
Filters::ActivateSteps.new(step_match_search, runtime.configuration),
Filters::ApplyAfterHooks.new(FailingAfterHook.new),
AddBeforeAndAfterHooks.new
]
execute_gherkin(filters) do
feature do
scenario do
end
end
end

expect( formatter.legacy_messages ).to eq([
:before_features,
:before_feature,
:before_tags,
:after_tags,
:feature_name,
:before_feature_element,
:before_tags,
:after_tags,
:scenario_name,
:exception,
:after_feature_element,
:after_feature,
:after_features
])
end
end

context 'with an exception in an around hook before the test case is run' do
class FailingAroundHookBeforeRunningTestCase
def find_around_hooks(test_case)
Expand All @@ -2003,6 +1911,7 @@ def find_around_hooks(test_case)
execute_gherkin(filters) do
feature do
scenario do
step 'passing'
end
end
end
Expand Down
Loading

0 comments on commit 10f0951

Please sign in to comment.