cucumber 2.0.0.beta.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/History.md +131 -32
- data/Rakefile +0 -2
- data/cucumber.gemspec +4 -3
- data/examples/i18n/ht/Rakefile +6 -0
- data/examples/i18n/ht/features/adisyon.feature +17 -0
- data/examples/i18n/ht/features/divizyon.feature +10 -0
- data/examples/i18n/ht/features/step_definitions/kalkilatris_steps.rb +25 -0
- data/examples/i18n/ht/lib/kalkilatris.rb +14 -0
- data/examples/tcl/features/step_definitions/fib_steps.rb +1 -1
- data/features/docs/cli/dry_run.feature +48 -0
- data/features/docs/cli/exclude_files.feature +1 -2
- data/features/docs/cli/run_specific_scenarios.feature +28 -66
- data/features/docs/cli/strict_mode.feature +24 -1
- data/features/docs/defining_steps/nested_steps.feature +49 -0
- data/features/docs/defining_steps/skip_scenario.feature +31 -2
- data/features/docs/defining_steps/snippets.feature +15 -0
- data/features/docs/exception_in_after_step_hook.feature +1 -1
- data/features/docs/exception_in_around_hook.feature +80 -0
- data/features/docs/extending_cucumber/custom_filter.feature +29 -0
- data/features/docs/extending_cucumber/custom_formatter.feature +65 -7
- data/features/docs/formatters/debug_formatter.feature +24 -17
- data/features/docs/formatters/json_formatter.feature +65 -1
- data/features/docs/formatters/junit_formatter.feature +40 -0
- data/features/docs/formatters/pretty_formatter.feature +42 -0
- data/features/docs/formatters/rerun_formatter.feature +3 -2
- data/features/docs/getting_started.feature +1 -1
- data/features/docs/{wire_protocol_erb.feature → wire_protocol/erb_configuration.feature} +2 -2
- data/features/docs/wire_protocol/handle_unexpected_response.feature +30 -0
- data/features/docs/wire_protocol/invoke_message.feature +216 -0
- data/features/docs/wire_protocol/readme.md +26 -0
- data/features/docs/wire_protocol/snippets_message.feature +51 -0
- data/features/docs/wire_protocol/step_matches_message.feature +81 -0
- data/features/docs/{wire_protocol_table_diffing.feature → wire_protocol/table_diffing.feature} +1 -0
- data/features/docs/{wire_protocol_tags.feature → wire_protocol/tags.feature} +1 -0
- data/features/docs/{wire_protocol_timeouts.feature → wire_protocol/timeouts.feature} +1 -0
- data/features/docs/work_in_progress.feature +1 -1
- data/features/docs/writing_support_code/after_hooks.feature +24 -0
- data/features/docs/writing_support_code/around_hooks.feature +31 -0
- data/features/docs/writing_support_code/before_hook.feature +7 -3
- data/features/docs/writing_support_code/tagged_hooks.feature +44 -6
- data/features/lib/step_definitions/wire_steps.rb +18 -1
- data/features/lib/support/fake_wire_server.rb +10 -7
- data/lib/cucumber/cli/configuration.rb +6 -11
- data/lib/cucumber/cli/main.rb +2 -2
- data/lib/cucumber/cli/options.rb +8 -1
- data/lib/cucumber/cli/profile_loader.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +1 -1
- data/lib/cucumber/encoding.rb +5 -0
- data/lib/cucumber/errors.rb +8 -0
- data/lib/cucumber/file_specs.rb +3 -1
- data/lib/cucumber/filters/activate_steps.rb +33 -0
- data/lib/cucumber/filters/apply_after_hooks.rb +9 -0
- data/lib/cucumber/filters/apply_after_step_hooks.rb +12 -0
- data/lib/cucumber/filters/apply_around_hooks.rb +12 -0
- data/lib/cucumber/filters/apply_before_hooks.rb +9 -0
- data/lib/cucumber/{runtime → filters}/gated_receiver.rb +5 -1
- data/lib/cucumber/filters/prepare_world.rb +45 -0
- data/lib/cucumber/filters/quit.rb +28 -0
- data/lib/cucumber/filters/randomizer.rb +40 -0
- data/lib/cucumber/{runtime → filters}/tag_limits/test_case_index.rb +4 -2
- data/lib/cucumber/{runtime → filters}/tag_limits/verifier.rb +4 -2
- data/lib/cucumber/filters/tag_limits.rb +45 -0
- data/lib/cucumber/filters.rb +9 -0
- data/lib/cucumber/formatter/ansicolor.rb +0 -8
- data/lib/cucumber/formatter/console.rb +37 -20
- data/lib/cucumber/formatter/debug.rb +1 -8
- data/lib/cucumber/formatter/fanout.rb +27 -0
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +10 -9
- data/lib/cucumber/formatter/html.rb +31 -6
- data/lib/cucumber/formatter/ignore_missing_messages.rb +20 -0
- data/lib/cucumber/formatter/junit.rb +97 -2
- data/lib/cucumber/formatter/legacy_api/adapter.rb +1060 -0
- data/lib/cucumber/formatter/legacy_api/ast.rb +376 -0
- data/lib/cucumber/formatter/legacy_api/results.rb +51 -0
- data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +30 -0
- data/lib/cucumber/formatter/pretty.rb +14 -0
- data/lib/cucumber/formatter/progress.rb +10 -0
- data/lib/cucumber/formatter/rerun.rb +14 -88
- data/lib/cucumber/hooks.rb +97 -0
- data/lib/cucumber/language_support/language_methods.rb +0 -54
- data/lib/cucumber/multiline_argument/data_table.rb +41 -29
- data/lib/cucumber/platform.rb +3 -3
- data/lib/cucumber/project_initializer.rb +43 -0
- data/lib/cucumber/rb_support/rb_hook.rb +2 -2
- data/lib/cucumber/rb_support/rb_step_definition.rb +11 -2
- data/lib/cucumber/rb_support/rb_transform.rb +3 -1
- data/lib/cucumber/rb_support/rb_world.rb +2 -2
- data/lib/cucumber/rb_support/snippet.rb +1 -1
- data/lib/cucumber/rspec/doubles.rb +1 -1
- data/lib/cucumber/running_test_case.rb +115 -0
- data/lib/cucumber/runtime/after_hooks.rb +24 -0
- data/lib/cucumber/runtime/before_hooks.rb +23 -0
- data/lib/cucumber/runtime/for_programming_languages.rb +4 -8
- data/lib/cucumber/runtime/step_hooks.rb +22 -0
- data/lib/cucumber/runtime/support_code.rb +70 -5
- data/lib/cucumber/runtime.rb +56 -112
- data/lib/cucumber/step_match.rb +26 -2
- data/lib/cucumber.rb +7 -3
- data/spec/cucumber/cli/configuration_spec.rb +16 -1
- data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
- data/spec/cucumber/core_ext/instance_exec_spec.rb +4 -0
- data/spec/cucumber/file_specs_spec.rb +21 -2
- data/spec/cucumber/filters/activate_steps_spec.rb +57 -0
- data/spec/cucumber/{runtime → filters}/gated_receiver_spec.rb +3 -3
- data/spec/cucumber/{runtime → filters}/tag_limits/test_case_index_spec.rb +3 -3
- data/spec/cucumber/{runtime → filters}/tag_limits/verifier_spec.rb +4 -4
- data/spec/cucumber/{runtime/tag_limits/filter_spec.rb → filters/tag_limits_spec.rb} +6 -6
- data/spec/cucumber/formatter/debug_spec.rb +25 -530
- data/spec/cucumber/formatter/html_spec.rb +140 -0
- data/spec/cucumber/formatter/junit_spec.rb +212 -156
- data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +2090 -0
- data/spec/cucumber/formatter/pretty_spec.rb +248 -2
- data/spec/cucumber/formatter/rerun_spec.rb +107 -0
- data/spec/cucumber/formatter/spec_helper.rb +17 -8
- data/spec/cucumber/hooks_spec.rb +30 -0
- data/spec/cucumber/multiline_argument/data_table_spec.rb +53 -47
- data/spec/cucumber/project_initializer_spec.rb +87 -0
- data/spec/cucumber/rb_support/rb_language_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +32 -7
- data/spec/cucumber/rb_support/rb_transform_spec.rb +20 -0
- data/spec/cucumber/rb_support/snippet_spec.rb +6 -6
- data/spec/cucumber/running_test_case_spec.rb +83 -0
- data/spec/cucumber/runtime_spec.rb +1 -5
- data/spec/spec_helper.rb +3 -4
- metadata +149 -107
- data/bin/cuke +0 -60
- data/features/docs/extending_cucumber/formatter_callbacks.feature +0 -370
- data/features/docs/output_from_hooks.feature +0 -128
- data/features/docs/report_called_undefined_steps.feature +0 -57
- data/features/docs/wire_protocol.feature +0 -337
- data/gem_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/gem_tasks/yard/default/layout/html/footer.erb +0 -5
- data/gem_tasks/yard/default/layout/html/index.erb +0 -1
- data/gem_tasks/yard/default/layout/html/layout.erb +0 -25
- data/gem_tasks/yard/default/layout/html/logo.erb +0 -1
- data/gem_tasks/yard/default/layout/html/setup.rb +0 -4
- data/gem_tasks/yard.rake +0 -43
- data/lib/cucumber/mappings.rb +0 -238
- data/lib/cucumber/reports/legacy_formatter.rb +0 -1349
- data/lib/cucumber/runtime/results.rb +0 -64
- data/lib/cucumber/runtime/tag_limits/filter.rb +0 -31
- data/lib/cucumber/runtime/tag_limits.rb +0 -15
- data/spec/cucumber/mappings_spec.rb +0 -180
- data/spec/cucumber/reports/legacy_formatter_spec.rb +0 -1860
- data/spec/cucumber/runtime/results_spec.rb +0 -88
|
@@ -10,8 +10,14 @@ Feature: Strict mode
|
|
|
10
10
|
Scenario: Missing
|
|
11
11
|
Given this step passes
|
|
12
12
|
"""
|
|
13
|
+
And a file named "features/pending.feature" with:
|
|
14
|
+
"""
|
|
15
|
+
Feature: Pending
|
|
16
|
+
Scenario: Pending
|
|
17
|
+
Given this step is pending
|
|
18
|
+
"""
|
|
13
19
|
|
|
14
|
-
Scenario: Fail with --strict
|
|
20
|
+
Scenario: Fail with --strict due to undefined step
|
|
15
21
|
When I run `cucumber -q features/missing.feature --strict`
|
|
16
22
|
Then it should fail with:
|
|
17
23
|
"""
|
|
@@ -26,6 +32,23 @@ Feature: Strict mode
|
|
|
26
32
|
1 step (1 undefined)
|
|
27
33
|
"""
|
|
28
34
|
|
|
35
|
+
Scenario: Fail with --strict due to pending step
|
|
36
|
+
Given the standard step definitions
|
|
37
|
+
When I run `cucumber -q features/pending.feature --strict`
|
|
38
|
+
Then it should fail with:
|
|
39
|
+
"""
|
|
40
|
+
Feature: Pending
|
|
41
|
+
|
|
42
|
+
Scenario: Pending
|
|
43
|
+
Given this step is pending
|
|
44
|
+
TODO (Cucumber::Pending)
|
|
45
|
+
./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
|
|
46
|
+
features/pending.feature:3:in `Given this step is pending'
|
|
47
|
+
|
|
48
|
+
1 scenario (1 pending)
|
|
49
|
+
1 step (1 pending)
|
|
50
|
+
"""
|
|
51
|
+
|
|
29
52
|
Scenario: Succeed with --strict
|
|
30
53
|
Given the standard step definitions
|
|
31
54
|
When I run `cucumber -q features/missing.feature --strict`
|
|
@@ -127,3 +127,52 @@ Feature: Nested Steps
|
|
|
127
127
|
1 scenario (1 failed)
|
|
128
128
|
1 step (1 failed)
|
|
129
129
|
"""
|
|
130
|
+
|
|
131
|
+
Scenario: Undefined nested step
|
|
132
|
+
Given a file named "features/call_undefined_step_from_step_def.feature" with:
|
|
133
|
+
"""
|
|
134
|
+
Feature: Calling undefined step
|
|
135
|
+
|
|
136
|
+
Scenario: Call directly
|
|
137
|
+
Given a step that calls an undefined step
|
|
138
|
+
|
|
139
|
+
Scenario: Call via another
|
|
140
|
+
Given a step that calls a step that calls an undefined step
|
|
141
|
+
"""
|
|
142
|
+
And a file named "features/step_definitions/steps.rb" with:
|
|
143
|
+
"""
|
|
144
|
+
Given /^a step that calls an undefined step$/ do
|
|
145
|
+
step 'this does not exist'
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Given /^a step that calls a step that calls an undefined step$/ do
|
|
149
|
+
step 'a step that calls an undefined step'
|
|
150
|
+
end
|
|
151
|
+
"""
|
|
152
|
+
When I run `cucumber -q features/call_undefined_step_from_step_def.feature`
|
|
153
|
+
Then it should fail with exactly:
|
|
154
|
+
"""
|
|
155
|
+
Feature: Calling undefined step
|
|
156
|
+
|
|
157
|
+
Scenario: Call directly
|
|
158
|
+
Given a step that calls an undefined step
|
|
159
|
+
Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
|
|
160
|
+
./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
|
|
161
|
+
features/call_undefined_step_from_step_def.feature:4:in `Given a step that calls an undefined step'
|
|
162
|
+
|
|
163
|
+
Scenario: Call via another
|
|
164
|
+
Given a step that calls a step that calls an undefined step
|
|
165
|
+
Undefined dynamic step: "this does not exist" (Cucumber::UndefinedDynamicStep)
|
|
166
|
+
./features/step_definitions/steps.rb:2:in `/^a step that calls an undefined step$/'
|
|
167
|
+
./features/step_definitions/steps.rb:6:in `/^a step that calls a step that calls an undefined step$/'
|
|
168
|
+
features/call_undefined_step_from_step_def.feature:7:in `Given a step that calls a step that calls an undefined step'
|
|
169
|
+
|
|
170
|
+
Failing Scenarios:
|
|
171
|
+
cucumber features/call_undefined_step_from_step_def.feature:3
|
|
172
|
+
cucumber features/call_undefined_step_from_step_def.feature:6
|
|
173
|
+
|
|
174
|
+
2 scenarios (2 failed)
|
|
175
|
+
2 steps (2 failed)
|
|
176
|
+
0m0.012s
|
|
177
|
+
|
|
178
|
+
"""
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Feature: Skip Scenario
|
|
2
|
-
-
|
|
3
2
|
|
|
4
|
-
Scenario: With a
|
|
3
|
+
Scenario: With a passing step
|
|
5
4
|
Given a file named "features/test.feature" with:
|
|
6
5
|
"""
|
|
7
6
|
Feature: test
|
|
@@ -31,3 +30,33 @@ Feature: Skip Scenario
|
|
|
31
30
|
|
|
32
31
|
"""
|
|
33
32
|
|
|
33
|
+
Scenario: Use legacy API from a hook
|
|
34
|
+
Given a file named "features/test.feature" with:
|
|
35
|
+
"""
|
|
36
|
+
Feature: test
|
|
37
|
+
Scenario: test
|
|
38
|
+
Given this step passes
|
|
39
|
+
And this step passes
|
|
40
|
+
"""
|
|
41
|
+
And the standard step definitions
|
|
42
|
+
And a file named "features/support/hook.rb" with:
|
|
43
|
+
"""
|
|
44
|
+
Before do |scenario|
|
|
45
|
+
scenario.skip_invoke!
|
|
46
|
+
end
|
|
47
|
+
"""
|
|
48
|
+
When I run `cucumber -q`
|
|
49
|
+
Then it should pass with:
|
|
50
|
+
"""
|
|
51
|
+
Feature: test
|
|
52
|
+
|
|
53
|
+
Scenario: test
|
|
54
|
+
Given this step passes
|
|
55
|
+
And this step passes
|
|
56
|
+
|
|
57
|
+
1 scenario (1 skipped)
|
|
58
|
+
2 steps (2 skipped)
|
|
59
|
+
0m0.012s
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
|
|
@@ -13,6 +13,9 @@ Feature: Snippets
|
|
|
13
13
|
\"\"\"
|
|
14
14
|
example with <html> entities
|
|
15
15
|
\"\"\"
|
|
16
|
+
When a simple when step
|
|
17
|
+
And another when step
|
|
18
|
+
Then a simple then step
|
|
16
19
|
"""
|
|
17
20
|
When I run `cucumber features/undefined_steps.feature -s`
|
|
18
21
|
Then the output should contain:
|
|
@@ -20,6 +23,18 @@ Feature: Snippets
|
|
|
20
23
|
Given(/^a pystring$/) do |string|
|
|
21
24
|
pending # Write code here that turns the phrase above into concrete actions
|
|
22
25
|
end
|
|
26
|
+
|
|
27
|
+
When(/^a simple when step$/) do
|
|
28
|
+
pending # Write code here that turns the phrase above into concrete actions
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
When(/^another when step$/) do
|
|
32
|
+
pending # Write code here that turns the phrase above into concrete actions
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Then(/^a simple then step$/) do
|
|
36
|
+
pending # Write code here that turns the phrase above into concrete actions
|
|
37
|
+
end
|
|
23
38
|
"""
|
|
24
39
|
|
|
25
40
|
Scenario: Snippet for undefined step with a step table
|
|
@@ -94,7 +94,7 @@ Feature: Exception in AfterStep Block
|
|
|
94
94
|
Given this step passes # features/step_definitions/steps.rb:1
|
|
95
95
|
|
|
96
96
|
Failing Scenarios:
|
|
97
|
-
cucumber features/naughty_step_in_scenario_outline.feature:9 # Scenario Outline: Naughty Step, Examples (
|
|
97
|
+
cucumber features/naughty_step_in_scenario_outline.feature:9 # Scenario Outline: Naughty Step, Examples (#2)
|
|
98
98
|
|
|
99
99
|
4 scenarios (1 failed, 3 passed)
|
|
100
100
|
4 steps (4 passed)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Feature: Exceptions in Around Hooks
|
|
2
|
+
|
|
3
|
+
Around hooks are awkward beasts to handle internally.
|
|
4
|
+
|
|
5
|
+
Right now, if there's an error in your Around hook before you call `block.call`,
|
|
6
|
+
we won't even print the steps for the scenario.
|
|
7
|
+
|
|
8
|
+
This is because that `block.call` invokes all the logic that would tell Cucumber's
|
|
9
|
+
UI about the steps in your scenario. If we never reach that code, we'll never be
|
|
10
|
+
told about them.
|
|
11
|
+
|
|
12
|
+
There's another scenario to consider, where the exception occurs after the steps
|
|
13
|
+
have been run. How would we want to report in that case?
|
|
14
|
+
|
|
15
|
+
Scenario: Exception before the test case is run
|
|
16
|
+
Given the standard step definitions
|
|
17
|
+
And a file named "features/support/env.rb" with:
|
|
18
|
+
"""
|
|
19
|
+
Around do |scenario, block|
|
|
20
|
+
fail "this should be reported"
|
|
21
|
+
block.call
|
|
22
|
+
end
|
|
23
|
+
"""
|
|
24
|
+
And a file named "features/test.feature" with:
|
|
25
|
+
"""
|
|
26
|
+
Feature:
|
|
27
|
+
Scenario:
|
|
28
|
+
Given this step passes
|
|
29
|
+
"""
|
|
30
|
+
When I run `cucumber -q`
|
|
31
|
+
Then it should fail with exactly:
|
|
32
|
+
"""
|
|
33
|
+
Feature:
|
|
34
|
+
|
|
35
|
+
Scenario:
|
|
36
|
+
this should be reported (RuntimeError)
|
|
37
|
+
./features/support/env.rb:2:in `Around'
|
|
38
|
+
|
|
39
|
+
Failing Scenarios:
|
|
40
|
+
cucumber features/test.feature:2
|
|
41
|
+
|
|
42
|
+
1 scenario (1 failed)
|
|
43
|
+
0 steps
|
|
44
|
+
0m0.012s
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
Scenario: Exception after the test case is run
|
|
49
|
+
Given the standard step definitions
|
|
50
|
+
And a file named "features/support/env.rb" with:
|
|
51
|
+
"""
|
|
52
|
+
Around do |scenario, block|
|
|
53
|
+
block.call
|
|
54
|
+
fail "this should be reported"
|
|
55
|
+
end
|
|
56
|
+
"""
|
|
57
|
+
And a file named "features/test.feature" with:
|
|
58
|
+
"""
|
|
59
|
+
Feature:
|
|
60
|
+
Scenario:
|
|
61
|
+
Given this step passes
|
|
62
|
+
"""
|
|
63
|
+
When I run `cucumber -q`
|
|
64
|
+
Then it should fail with exactly:
|
|
65
|
+
"""
|
|
66
|
+
Feature:
|
|
67
|
+
|
|
68
|
+
Scenario:
|
|
69
|
+
Given this step passes
|
|
70
|
+
this should be reported (RuntimeError)
|
|
71
|
+
./features/support/env.rb:3:in `Around'
|
|
72
|
+
|
|
73
|
+
Failing Scenarios:
|
|
74
|
+
cucumber features/test.feature:2
|
|
75
|
+
|
|
76
|
+
1 scenario (1 failed)
|
|
77
|
+
1 step (1 passed)
|
|
78
|
+
0m0.012s
|
|
79
|
+
|
|
80
|
+
"""
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Feature: Custom filter
|
|
2
|
+
|
|
3
|
+
Scenario: Add a custom filter via AfterConfiguration hook
|
|
4
|
+
Given a file named "features/test.feature" with:
|
|
5
|
+
"""
|
|
6
|
+
Feature:
|
|
7
|
+
Scenario:
|
|
8
|
+
Given my special step
|
|
9
|
+
"""
|
|
10
|
+
And a file named "features/support/my_filter.rb" with:
|
|
11
|
+
"""
|
|
12
|
+
require 'cucumber/core/filter'
|
|
13
|
+
|
|
14
|
+
MakeAnythingPass = Cucumber::Core::Filter.new do
|
|
15
|
+
def test_case(test_case)
|
|
16
|
+
activated_steps = test_case.test_steps.map do |test_step|
|
|
17
|
+
test_step.with_action { }
|
|
18
|
+
end
|
|
19
|
+
test_case.with_steps(activated_steps).describe_to receiver
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
AfterConfiguration do |config|
|
|
24
|
+
config.filters << MakeAnythingPass.new
|
|
25
|
+
end
|
|
26
|
+
"""
|
|
27
|
+
When I run `cucumber --strict`
|
|
28
|
+
Then it should pass
|
|
29
|
+
|
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
Feature: Custom Formatter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Background:
|
|
4
4
|
Given a file named "features/f.feature" with:
|
|
5
5
|
"""
|
|
6
6
|
Feature: I'll use my own
|
|
7
|
-
|
|
8
|
-
Scenario: just print me
|
|
7
|
+
Scenario: Just print me
|
|
9
8
|
Given this step passes
|
|
10
9
|
"""
|
|
11
10
|
And the standard step definitions
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
Scenario: Use the new API
|
|
13
|
+
Given a file named "features/support/custom_formatter.rb" with:
|
|
13
14
|
"""
|
|
14
|
-
module
|
|
15
|
-
class
|
|
15
|
+
module MyCustom
|
|
16
|
+
class Formatter
|
|
17
|
+
def initialize(runtime, io, options)
|
|
18
|
+
@io = io
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def before_test_case(test_case)
|
|
22
|
+
feature = test_case.source.first
|
|
23
|
+
scenario = test_case.source.last
|
|
24
|
+
@io.puts feature.short_name.upcase
|
|
25
|
+
@io.puts " #{scenario.name.upcase}"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
"""
|
|
30
|
+
When I run `cucumber features/f.feature --format MyCustom::Formatter`
|
|
31
|
+
Then it should pass with exactly:
|
|
32
|
+
"""
|
|
33
|
+
I'LL USE MY OWN
|
|
34
|
+
JUST PRINT ME
|
|
35
|
+
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
Scenario: Use the legacy API
|
|
39
|
+
Given a file named "features/support/custom_legacy_formatter.rb" with:
|
|
40
|
+
"""
|
|
41
|
+
module MyCustom
|
|
42
|
+
class LegacyFormatter
|
|
16
43
|
def initialize(runtime, io, options)
|
|
17
44
|
@io = io
|
|
18
45
|
end
|
|
@@ -27,7 +54,38 @@ Feature: Custom Formatter
|
|
|
27
54
|
end
|
|
28
55
|
end
|
|
29
56
|
"""
|
|
30
|
-
When I run `cucumber features/f.feature --format
|
|
57
|
+
When I run `cucumber features/f.feature --format MyCustom::LegacyFormatter`
|
|
58
|
+
Then it should pass with exactly:
|
|
59
|
+
"""
|
|
60
|
+
I'LL USE MY OWN
|
|
61
|
+
JUST PRINT ME
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
Scenario: Use both
|
|
66
|
+
You can use a specific shim to opt-in to both APIs at once.
|
|
67
|
+
|
|
68
|
+
Given a file named "features/support/custom_mixed_formatter.rb" with:
|
|
69
|
+
"""
|
|
70
|
+
module MyCustom
|
|
71
|
+
class MixedFormatter
|
|
72
|
+
|
|
73
|
+
def initialize(runtime, io, options)
|
|
74
|
+
@io = io
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def before_test_case(test_case)
|
|
78
|
+
feature = test_case.source.first
|
|
79
|
+
@io.puts feature.short_name.upcase
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def scenario_name(keyword, name, file_colon_line, source_indent)
|
|
83
|
+
@io.puts " #{name.upcase}"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
"""
|
|
88
|
+
When I run `cucumber features/f.feature --format MyCustom::MixedFormatter`
|
|
31
89
|
Then it should pass with exactly:
|
|
32
90
|
"""
|
|
33
91
|
I'LL USE MY OWN
|
|
@@ -18,23 +18,30 @@ Feature: Debug formatter
|
|
|
18
18
|
Then the stderr should not contain anything
|
|
19
19
|
Then it should pass with:
|
|
20
20
|
"""
|
|
21
|
+
before_test_case
|
|
21
22
|
before_features
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
before_feature
|
|
24
|
+
before_tags
|
|
25
|
+
after_tags
|
|
26
|
+
feature_name
|
|
27
|
+
before_test_step
|
|
28
|
+
after_test_step
|
|
29
|
+
before_test_step
|
|
30
|
+
before_feature_element
|
|
31
|
+
before_tags
|
|
32
|
+
after_tags
|
|
33
|
+
scenario_name
|
|
34
|
+
before_steps
|
|
35
|
+
before_step
|
|
36
|
+
before_step_result
|
|
37
|
+
step_name
|
|
38
|
+
after_step_result
|
|
39
|
+
after_step
|
|
40
|
+
after_test_step
|
|
41
|
+
after_steps
|
|
42
|
+
after_feature_element
|
|
43
|
+
after_test_case
|
|
44
|
+
after_feature
|
|
39
45
|
after_features
|
|
46
|
+
done
|
|
40
47
|
"""
|
|
@@ -82,6 +82,14 @@ Feature: JSON output formatter
|
|
|
82
82
|
Scenario:
|
|
83
83
|
Given I embed data directly
|
|
84
84
|
|
|
85
|
+
Scenario Outline:
|
|
86
|
+
Given I embed data directly
|
|
87
|
+
|
|
88
|
+
Examples:
|
|
89
|
+
| dummy |
|
|
90
|
+
| 1 |
|
|
91
|
+
| 2 |
|
|
92
|
+
|
|
85
93
|
"""
|
|
86
94
|
And a file named "features/out_scenario_out_scenario_outline.feature" with:
|
|
87
95
|
"""
|
|
@@ -613,7 +621,7 @@ Feature: JSON output formatter
|
|
|
613
621
|
|
|
614
622
|
@spawn
|
|
615
623
|
Scenario: embedding data directly
|
|
616
|
-
When I run `cucumber -b --format json features/embed_data_directly.feature`
|
|
624
|
+
When I run `cucumber -b --format json -x features/embed_data_directly.feature`
|
|
617
625
|
Then it should pass with JSON:
|
|
618
626
|
"""
|
|
619
627
|
[
|
|
@@ -652,6 +660,62 @@ Feature: JSON output formatter
|
|
|
652
660
|
}
|
|
653
661
|
}
|
|
654
662
|
]
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"keyword": "Scenario Outline",
|
|
666
|
+
"name": "",
|
|
667
|
+
"line": 11,
|
|
668
|
+
"description": "",
|
|
669
|
+
"id": "an-embed-data-directly-feature;;;2",
|
|
670
|
+
"type": "scenario",
|
|
671
|
+
"steps": [
|
|
672
|
+
{
|
|
673
|
+
"keyword": "Given ",
|
|
674
|
+
"name": "I embed data directly",
|
|
675
|
+
"line": 11,
|
|
676
|
+
"embeddings": [
|
|
677
|
+
{
|
|
678
|
+
"mime_type": "mime-type",
|
|
679
|
+
"data": "YWJj"
|
|
680
|
+
}
|
|
681
|
+
],
|
|
682
|
+
"match": {
|
|
683
|
+
"location": "features/step_definitions/json_steps.rb:10"
|
|
684
|
+
},
|
|
685
|
+
"result": {
|
|
686
|
+
"status": "passed",
|
|
687
|
+
"duration": 1
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
]
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
"keyword": "Scenario Outline",
|
|
694
|
+
"name": "",
|
|
695
|
+
"line": 12,
|
|
696
|
+
"description": "",
|
|
697
|
+
"id": "an-embed-data-directly-feature;;;3",
|
|
698
|
+
"type": "scenario",
|
|
699
|
+
"steps": [
|
|
700
|
+
{
|
|
701
|
+
"keyword": "Given ",
|
|
702
|
+
"name": "I embed data directly",
|
|
703
|
+
"line": 12,
|
|
704
|
+
"embeddings": [
|
|
705
|
+
{
|
|
706
|
+
"mime_type": "mime-type",
|
|
707
|
+
"data": "YWJj"
|
|
708
|
+
}
|
|
709
|
+
],
|
|
710
|
+
"match": {
|
|
711
|
+
"location": "features/step_definitions/json_steps.rb:10"
|
|
712
|
+
},
|
|
713
|
+
"result": {
|
|
714
|
+
"status": "passed",
|
|
715
|
+
"duration": 1
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
]
|
|
655
719
|
}
|
|
656
720
|
]
|
|
657
721
|
}
|
|
@@ -274,3 +274,43 @@ You *must* specify --out DIR for the junit formatter
|
|
|
274
274
|
</testsuite>
|
|
275
275
|
|
|
276
276
|
"""
|
|
277
|
+
|
|
278
|
+
Scenario: one feature, one scenario outline, two examples: one passing, one failing with --expand option
|
|
279
|
+
When I run `cucumber --expand --format junit --out tmp/ features/scenario_outline.feature`
|
|
280
|
+
Then it should fail with exactly:
|
|
281
|
+
"""
|
|
282
|
+
|
|
283
|
+
"""
|
|
284
|
+
And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
|
|
285
|
+
"""
|
|
286
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
287
|
+
<testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="Scenario outlines">
|
|
288
|
+
<testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
|
|
289
|
+
<system-out/>
|
|
290
|
+
<system-err/>
|
|
291
|
+
</testcase>
|
|
292
|
+
<testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
|
|
293
|
+
<failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
|
|
294
|
+
<![CDATA[Scenario Outline: Using scenario outlines
|
|
295
|
+
|
|
296
|
+
Example row: | fails |
|
|
297
|
+
|
|
298
|
+
Message:
|
|
299
|
+
]]>
|
|
300
|
+
<![CDATA[ (RuntimeError)
|
|
301
|
+
./features/step_definitions/steps.rb:4:in `/^this step fails$/'
|
|
302
|
+
features/scenario_outline.feature:9:in `Given this step fails'
|
|
303
|
+
features/scenario_outline.feature:4:in `Given this step <type>']]>
|
|
304
|
+
</failure>
|
|
305
|
+
<system-out/>
|
|
306
|
+
<system-err/>
|
|
307
|
+
</testcase>
|
|
308
|
+
<system-out>
|
|
309
|
+
<![CDATA[]]>
|
|
310
|
+
</system-out>
|
|
311
|
+
<system-err>
|
|
312
|
+
<![CDATA[]]>
|
|
313
|
+
</system-err>
|
|
314
|
+
</testsuite>
|
|
315
|
+
|
|
316
|
+
"""
|
|
@@ -28,4 +28,46 @@ Feature: Pretty output formatter
|
|
|
28
28
|
"""
|
|
29
29
|
Using the default profile...
|
|
30
30
|
"""
|
|
31
|
+
Scenario: Hook output should be printed before hook exception
|
|
32
|
+
Given the standard step definitions
|
|
33
|
+
And a file named "features/test.feature" with:
|
|
34
|
+
"""
|
|
35
|
+
Feature:
|
|
36
|
+
Scenario:
|
|
37
|
+
Given this step passes
|
|
38
|
+
"""
|
|
39
|
+
And a file named "features/step_definitions/output_steps.rb" with:
|
|
40
|
+
"""
|
|
41
|
+
Before do
|
|
42
|
+
puts "Before hook"
|
|
43
|
+
end
|
|
31
44
|
|
|
45
|
+
AfterStep do
|
|
46
|
+
puts "AfterStep hook"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
After do
|
|
50
|
+
puts "After hook"
|
|
51
|
+
raise "error"
|
|
52
|
+
end
|
|
53
|
+
"""
|
|
54
|
+
When I run `cucumber -q -f pretty features/test.feature`
|
|
55
|
+
Then the stderr should not contain anything
|
|
56
|
+
Then it should fail with:
|
|
57
|
+
"""
|
|
58
|
+
Feature:
|
|
59
|
+
|
|
60
|
+
Scenario:
|
|
61
|
+
Before hook
|
|
62
|
+
Given this step passes
|
|
63
|
+
AfterStep hook
|
|
64
|
+
After hook
|
|
65
|
+
error (RuntimeError)
|
|
66
|
+
./features/step_definitions/output_steps.rb:11:in `After'
|
|
67
|
+
|
|
68
|
+
Failing Scenarios:
|
|
69
|
+
cucumber features/test.feature:2
|
|
70
|
+
|
|
71
|
+
1 scenario (1 failed)
|
|
72
|
+
1 step (1 passed)
|
|
73
|
+
"""
|
|
@@ -113,8 +113,9 @@ Feature: Rerun formatter
|
|
|
113
113
|
features/failing_background_outline.feature:11:12
|
|
114
114
|
"""
|
|
115
115
|
|
|
116
|
-
Scenario: Scenario outlines with expand
|
|
117
|
-
|
|
116
|
+
Scenario: Scenario outlines with expand
|
|
117
|
+
For details see https://github.com/cucumber/cucumber/issues/503
|
|
118
|
+
|
|
118
119
|
Given a file named "features/one_passing_one_failing.feature" with:
|
|
119
120
|
"""
|
|
120
121
|
Feature: One passing example, one failing example
|
|
@@ -9,7 +9,7 @@ Feature: Getting started
|
|
|
9
9
|
When I run `cucumber`
|
|
10
10
|
Then it should fail with:
|
|
11
11
|
"""
|
|
12
|
-
No such file or directory - features.
|
|
12
|
+
No such file or directory - features. You can use `cucumber --init` to get started.
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
15
|
Scenario: Accidentally run Cucumber in a folder with Ruby files in it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@wire
|
|
2
|
-
Feature:
|
|
3
|
-
|
|
2
|
+
Feature: ERB configuration
|
|
3
|
+
|
|
4
4
|
As a developer on server with multiple users
|
|
5
5
|
I want to be able to configure which port my wire server runs on
|
|
6
6
|
So that I can avoid port conflicts
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@wire
|
|
2
|
+
Feature: Handle unexpected response
|
|
3
|
+
|
|
4
|
+
When the server sends us back a message we don't understand, this is how Cucumber will behave.
|
|
5
|
+
|
|
6
|
+
Background:
|
|
7
|
+
Given a file named "features/wired.feature" with:
|
|
8
|
+
"""
|
|
9
|
+
Feature: High strung
|
|
10
|
+
Scenario: Wired
|
|
11
|
+
Given we're all wired
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
And a file named "features/step_definitions/some_remote_place.wire" with:
|
|
15
|
+
"""
|
|
16
|
+
host: localhost
|
|
17
|
+
port: 54321
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
Scenario: Unexpected response
|
|
22
|
+
Given there is a wire server running on port 54321 which understands the following protocol:
|
|
23
|
+
| request | response |
|
|
24
|
+
| ["begin_scenario"] | ["yikes"] |
|
|
25
|
+
| ["step_matches",{"name_to_match":"we're all wired"}] | ["success",[{"id":"1", "args":[]}]] |
|
|
26
|
+
When I run `cucumber -f pretty`
|
|
27
|
+
Then the output should contain:
|
|
28
|
+
"""
|
|
29
|
+
undefined method `handle_yikes'
|
|
30
|
+
"""
|