diff --git a/features/docs/defining_steps/ambiguous_steps.feature b/features/docs/defining_steps/ambiguous_steps.feature
index ed57623181..5d83633d20 100644
--- a/features/docs/defining_steps/ambiguous_steps.feature
+++ b/features/docs/defining_steps/ambiguous_steps.feature
@@ -2,7 +2,8 @@ Feature: Ambiguous Steps
When Cucumber searches for a step definition for a step, it might find multiple step
definitions that could match. In that case, it will give you an error that the step
- definitions are ambiguous.
+ definitions are ambiguous. Also when skipping an ambiguous step the error will occur
+ so ambiguous steps are not hidden by earlier failures.
You can also use a `--guess` mode, where it uses magic powers to try and figure
out which of those two step definitions is most likely to be the one you meant it
@@ -40,14 +41,14 @@ Feature: Ambiguous Steps
features/step_definitions.rb:5:in `/^an ambiguous step$/'
You can run again with --guess to make Cucumber be more smart about it
- (Cucumber::Ambiguous)
+ (Cucumber::Core::Test::Result::Ambiguous)
features/ambiguous.feature:5:in `an ambiguous step'
- Failing Scenarios:
+ Ambiguous Scenarios:
cucumber features/ambiguous.feature:3 # Scenario:
- 1 scenario (1 failed)
- 2 steps (1 failed, 1 passed)
+ 1 scenario (1 ambiguous)
+ 2 steps (1 ambiguous, 1 passed)
0m0.012s
"""
@@ -86,3 +87,50 @@ Feature: Ambiguous Steps
0m0.012s
"""
+
+ Scenario: Ambiguous steps after failed steps
+
+ Given a file named "features/ambiguous.feature" with:
+ """
+ Feature:
+
+ Scenario:
+ When a failed step
+ Then an ambiguous step
+
+ """
+ And a file named "features/step_definitions.rb" with:
+ """
+ When(/^a.*step$/) do
+ raise 'error'
+ end
+
+ Then(/^an ambiguous step$/) do
+ 'bar'
+ end
+
+ """
+ When I run `cucumber`
+ Then it should fail with:
+ """
+ When a failed step # features/step_definitions.rb:1
+ error (RuntimeError)
+ ./features/step_definitions.rb:2:in `/^a.*step$/'
+ features/ambiguous.feature:4:in `a failed step'
+ Then an ambiguous step # features/ambiguous.feature:5
+ Ambiguous match of "an ambiguous step":
+
+ features/step_definitions.rb:1:in `/^a.*step$/'
+ features/step_definitions.rb:5:in `/^an ambiguous step$/'
+
+ You can run again with --guess to make Cucumber be more smart about it
+ (Cucumber::Core::Test::Result::Ambiguous)
+
+ Failing Scenarios:
+ cucumber features/ambiguous.feature:3 # Scenario:
+
+ 1 scenario (1 failed)
+ 2 steps (1 failed, 1 ambiguous)
+ 0m0.012s
+
+ """
diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb
index 90c0b31c79..190d00144e 100644
--- a/lib/cucumber/formatter/ansicolor.rb
+++ b/lib/cucumber/formatter/ansicolor.rb
@@ -47,6 +47,8 @@ module Formatter
# * flaky_param - defaults to yellow,bold
# * failed - defaults to red
# * failed_param - defaults to red,bold
+ # * ambiguous - defaults to red
+ # * abmiguous_param - defaults to red,bold
# * passed - defaults to green
# * passed_param - defaults to green,bold
# * outline - defaults to cyan
@@ -72,6 +74,7 @@ module ANSIColor
'pending' => 'yellow',
'flaky' => 'yellow',
'failed' => 'red',
+ 'ambiguous' => 'red',
'passed' => 'green',
'outline' => 'cyan',
'skipped' => 'cyan',
diff --git a/lib/cucumber/formatter/duration_extractor.rb b/lib/cucumber/formatter/duration_extractor.rb
index 5917c272ef..d38a921c58 100644
--- a/lib/cucumber/formatter/duration_extractor.rb
+++ b/lib/cucumber/formatter/duration_extractor.rb
@@ -14,6 +14,8 @@ def passed(*) end
def failed(*) end
+ def ambiguous(*) end
+
def undefined(*) end
def skipped(*) end
diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb
index e457383df1..f4f9dba47d 100644
--- a/lib/cucumber/formatter/junit.rb
+++ b/lib/cucumber/formatter/junit.rb
@@ -131,7 +131,7 @@ def create_output_string(test_case, scenario, result, row_name)
end
def build_testcase(result, scenario_designation, output)
- duration = ResultBuilder.new(result).test_case_duration
+ duration = DurationExtractor.new(result).result_duration
@current_feature_data[:time] += duration
classname = @current_feature_data[:feature].name
filename = @current_feature_data[:uri]
@@ -234,32 +234,5 @@ def examples_table_row(row)
@name_suffix = " (outline example : #{@row_name})"
end
end
-
- class ResultBuilder
- attr_reader :test_case_duration
-
- def initialize(result)
- @test_case_duration = 0
- result.describe_to(self)
- end
-
- def passed(*) end
-
- def failed(*) end
-
- def undefined(*) end
-
- def skipped(*) end
-
- def pending(*) end
-
- def exception(*) end
-
- def duration(duration, *)
- duration.tap { |dur| @test_case_duration = dur.nanoseconds / 10**9.0 }
- end
-
- def attach(*) end
- end
end
end
diff --git a/lib/cucumber/formatter/progress.rb b/lib/cucumber/formatter/progress.rb
index 16e17245d2..88b2b0b2c7 100644
--- a/lib/cucumber/formatter/progress.rb
+++ b/lib/cucumber/formatter/progress.rb
@@ -94,6 +94,7 @@ def print_summary
CHARS = {
passed: '.',
failed: 'F',
+ ambiguous: 'A',
undefined: 'U',
pending: 'P',
skipped: '-'
diff --git a/lib/cucumber/step_match.rb b/lib/cucumber/step_match.rb
index 6737822402..fdd4f65403 100644
--- a/lib/cucumber/step_match.rb
+++ b/lib/cucumber/step_match.rb
@@ -148,7 +148,7 @@ def initialize(error)
end
def activate(test_step)
- test_step.with_action { raise @error }
+ test_step.with_unskippable_action { raise Core::Test::Result::Ambiguous, @error.message }
end
end
end