Skip to content
Browse files

Accept (and demonstrate) that Cucumber doesn't differentiate between …

…failures and errors.
  • Loading branch information...
1 parent 6423082 commit 8df0657d7a26fa074c99584e64f3dbfec3a8a080 @mathie mathie committed May 4, 2009
View
7 acceptance/cucumber/cucumber_example.feature
@@ -11,4 +11,9 @@ Feature: Example feature
Scenario: Lazy hacker
Given that I am a lazy hacker
And I don't bother writing cucumber features
- Then I should be fired
+ Then I should be fired
+
+ Scenario: Bad coder
+ Given that I can't code for peanuts
+ And I write step definitions that throw exceptions
+ Then I shouldn't be allowed out in public
View
10 acceptance/cucumber/step_definitions/development_steps.rb
@@ -18,3 +18,13 @@
Then /^I should be fired$/ do
end
+
+Given /^that I can't code for peanuts$/ do
+end
+
+Given /^I write step definitions that throw exceptions$/ do
+ raise RuntimeError, "User error!"
+end
+
+Then /^I shouldn't be allowed out in public$/ do
+end
View
19 acceptance/verification_spec.rb
@@ -64,9 +64,12 @@
end
describe "Cucumber acceptance" do
- it "should generate two XML files" do
+ it "should generate three XML files" do
File.exist?(File.join(REPORTS_DIR, 'CUCUMBER-Feature-Example-feature-Conscientious-developer.xml')).should == true
File.exist?(File.join(REPORTS_DIR, 'CUCUMBER-Feature-Example-feature-Lazy-hacker.xml')).should == true
+ File.exist?(File.join(REPORTS_DIR, 'CUCUMBER-Feature-Example-feature-Bad-coder.xml')).should == true
+
+ Dir["#{REPORTS_DIR}/CUCUMBER-*.xml"].length.should == 3
end
it "should have three tests and no failures for the conscientious developer" do
@@ -92,4 +95,18 @@
failures.size.should == 1
failures.first.attributes["type"].should == "Spec::Expectations::ExpectationNotMetError"
end
+
+ it "should have three tests and one failure for the bad coder" do
+ doc = File.open(File.join(REPORTS_DIR, 'CUCUMBER-Feature-Example-feature-Bad-coder.xml')) do |f|
+ REXML::Document.new(f)
+ end
+ doc.root.attributes["errors"].should == "0"
+ doc.root.attributes["failures"].should == "1"
+ doc.root.attributes["tests"].should == "3"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 3
+
+ failures = doc.root.elements.to_a("/testsuite/testcase/failure")
+ failures.size.should == 1
+ failures.first.attributes["type"].should == "RuntimeError"
+ end
end
View
2 lib/ci/reporter/cucumber.rb
@@ -27,7 +27,7 @@ def initialize(step)
end
def failure?
- step.exception.is_a? StandardError
+ true
end
def error?

0 comments on commit 8df0657

Please sign in to comment.
Something went wrong with that request. Please try again.