Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a spec. Fail if a step failed. Solves #205.

  • Loading branch information...
commit 4388c34f35b43f90ecc7f5315e926f119b6cddc3 1 parent 3994233
@tcwitte authored
View
4 lib/cucumber/runtime/results.rb
@@ -54,11 +54,11 @@ def failure?
if @configuration.wip?
scenarios(:passed).any?
else
- scenarios(:failed).any? ||
+ scenarios(:failed).any? || steps(:failed).any? ||

does it still need to check scenarios(:failed) as well as steps(:failed) ? I would have thought that steps(:failed) would cover both. Can you try it?

@tcwitte Owner
tcwitte added a note

I would be very surprised if steps fail but no scenario fails, I agree. However I would still keep the check there, because it's more robust and more symmetrical with the other checks. (On first sight it seems unlikely that a test can fail if none of the scenarios fail, but that is in fact possible -- #205)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
(@configuration.strict? && (steps(:undefined).any? || steps(:pending).any?))
end
end
end
end
-end
+end
View
81 spec/cucumber/runtime/results_spec.rb
@@ -0,0 +1,81 @@
+require 'spec_helper'
+
+module Cucumber
+ describe Runtime::Results do
+
+ let(:configuration) {double 'Configuration', :strict? => false}
+ let(:passed_scenario) {double 'Scenario', :status => :passed}
+ let(:failed_scenario) {double 'Scenario', :status => :failed}
+ let(:passed_step) {double 'Step', :status => :passed}
+ let(:failed_step) {double 'Step', :status => :failed}
+ let(:pending_step) {double 'Step', :status => :pending}
+ let(:undefined_step) {double 'Step', :status => :undefined}
+
+ subject {described_class.new(configuration)}
+
+ describe '#failure?' do
+ context 'feature is not work in progress' do
+ before do
+ configuration.stub(:wip? => false)
+ end
+
+ it 'should return true if a scenario failed' do
+ subject.scenario_visited(passed_scenario)
+ subject.scenario_visited(failed_scenario)
+ subject.should be_failure
+ end
+
+ it 'should return true if a step failed' do
+ subject.step_visited(failed_step)
+ subject.should be_failure
+ end
+
+ it 'should return false if there are no scenarios' do
+ subject.should_not be_failure
+ end
+
+ it 'should return false if all scenarios passed' do
+ subject.scenario_visited(passed_scenario)
+ subject.scenario_visited(passed_scenario)
+ subject.should_not be_failure
+ end
+
+ context 'configuration is strict' do
+ before do
+ configuration.stub(:strict? => true)
+ end
+
+ it 'should return true if a step is pending' do
+ subject.step_visited(pending_step)
+ subject.should be_failure
+ end
+
+ it 'should return true if a step is undefined' do
+ subject.step_visited(undefined_step)
+ subject.should be_failure
+ end
+ end
+ end
+
+ context 'feature is work in progress' do
+ before do
+ configuration.stub(:wip? => true)
+ end
+
+ it 'should return true if a scenario passed' do
+ subject.scenario_visited(passed_scenario)
+ subject.should be_failure
+ end
+
+ it 'should return false if there are no scenarios' do
+ subject.should_not be_failure
+ end
+
+ it 'should return false if all scenarios fail' do
+ subject.scenario_visited(failed_scenario)
+ subject.should_not be_failure
+ end
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.