Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change pending tests from 'success' status to 'skipped'

  • Loading branch information...
commit 83d2b95a7e6c96e822597dea41342e47d27c9ca0 1 parent ef2e3dc
@psndcsrv psndcsrv authored nicksieger committed
View
1  lib/ci/reporter/rspec.rb
@@ -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
View
24 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.
@@ -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)
@@ -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
@@ -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
@@ -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
View
7 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.
@@ -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")
@@ -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
@@ -147,4 +148,4 @@ def name.to_s; "object name"; end
@tc.finish
@tc.time.should >= 0
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.