Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Accept (and demonstrate) that Cucumber doesn't differentiate between …
Browse files Browse the repository at this point in the history
…failures and errors.
  • Loading branch information
mathie committed May 4, 2009
1 parent 6423082 commit 8df0657
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
7 changes: 6 additions & 1 deletion acceptance/cucumber/cucumber_example.feature
Expand Up @@ -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
10 changes: 10 additions & 0 deletions acceptance/cucumber/step_definitions/development_steps.rb
Expand Up @@ -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
19 changes: 18 additions & 1 deletion acceptance/verification_spec.rb
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/ci/reporter/cucumber.rb
Expand Up @@ -27,7 +27,7 @@ def initialize(step)
end

def failure?
step.exception.is_a? StandardError
true
end

def error?
Expand Down

0 comments on commit 8df0657

Please sign in to comment.