Skip to content

Commit

Permalink
Change pending tests from 'success' status to 'skipped'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Unger authored and nicksieger committed Mar 25, 2010
1 parent ef2e3dc commit 83d2b95
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/ci/reporter/rspec.rb
Expand Up @@ -97,6 +97,7 @@ def example_pending(*args)
spec = @suite.testcases.last
spec.finish
spec.name = "#{spec.name} (PENDING)"
spec.skipped = true
end

def start_dump
Expand Down
24 changes: 17 additions & 7 deletions lib/ci/reporter/test_suite.rb
@@ -1,4 +1,4 @@
# (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
# (c) Copyright 2006-2007, 2010 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.

Expand Down Expand Up @@ -36,7 +36,7 @@ def #{m}(*args, &block)
end

# Basic structure representing the running of a test suite. Used to time tests and store results.
class TestSuite < Struct.new(:name, :tests, :time, :failures, :errors, :assertions)
class TestSuite < Struct.new(:name, :tests, :time, :failures, :errors, :skipped, :assertions)
attr_accessor :testcases
attr_accessor :stdout, :stderr
def initialize(name)
Expand All @@ -59,6 +59,7 @@ def finish
self.time = Time.now - @start
self.failures = testcases.inject(0) {|sum,tc| sum += tc.failures.select{|f| f.failure? }.size }
self.errors = testcases.inject(0) {|sum,tc| sum += tc.failures.select{|f| f.error? }.size }
self.skipped = testcases.inject(0) {|sum,tc| sum += (tc.skipped? ? 1 : 0) }
self.stdout = @capture_out.finish if @capture_out
self.stderr = @capture_err.finish if @capture_err
end
Expand Down Expand Up @@ -103,6 +104,7 @@ def builder.trunc!(txt)
# Structure used to represent an individual test case. Used to time the test and store the result.
class TestCase < Struct.new(:name, :time, :assertions)
attr_accessor :failures
attr_accessor :skipped

def initialize(*args)
super
Expand All @@ -129,19 +131,27 @@ def error?
!failures.empty? && failures.detect {|f| f.error? }
end

def skipped?
return skipped
end

# Writes xml representing the test result to the provided builder.
def to_xml(builder)
attrs = {}
each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) unless v.nil? || v.to_s.empty?}
builder.testcase(attrs) do
failures.each do |failure|
builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
builder.text!(failure.message + " (#{failure.name})\n")
builder.text!(failure.location)
if skipped
builder.skipped
else
failures.each do |failure|
builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
builder.text!(failure.message + " (#{failure.name})\n")
builder.text!(failure.location)
end
end
end
end
end
end
end
end
end
7 changes: 4 additions & 3 deletions spec/ci/reporter/test_suite_spec.rb
@@ -1,4 +1,4 @@
# (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
# (c) Copyright 2006-2007, 2010 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.

Expand Down Expand Up @@ -79,6 +79,7 @@ def name.to_s; "object name"; end

@suite.start
@suite.testcases << CI::Reporter::TestCase.new("example test")
@suite.testcases << CI::Reporter::TestCase.new("skipped test").tap {|tc| tc.skipped = true }
@suite.testcases << CI::Reporter::TestCase.new("failure test")
@suite.testcases.last.failures << failure
@suite.testcases << CI::Reporter::TestCase.new("error test")
Expand All @@ -94,7 +95,7 @@ def name.to_s; "object name"; end
testsuite.attributes["assertions"].should == "11"

testcases = testsuite.elements.to_a("testcase")
testcases.length.should == 3
testcases.length.should == 4
end

it "should contain full exception type and message in location element" do
Expand Down Expand Up @@ -147,4 +148,4 @@ def name.to_s; "object name"; end
@tc.finish
@tc.time.should >= 0
end
end
end

0 comments on commit 83d2b95

Please sign in to comment.