Permalink
Browse files

Add assertions attribute to individual test cases -- Test::Unit only

(Andy Sipe)


git-svn-id: http://svn.caldersphere.net/svn/main/rubyforge/ci_reporter/trunk@101 b03c2d0b-2f10-0410-a2f9-fc8001506dfa
  • Loading branch information...
1 parent 172f0a1 commit a68606b8c964121e3b20b73b63244f3f53f641f4 @nicksieger nicksieger committed Jun 18, 2007
Showing with 10 additions and 2 deletions.
  1. +1 −0 History.txt
  2. +2 −2 lib/ci/reporter/test_suite.rb
  3. +3 −0 lib/ci/reporter/test_unit.rb
  4. +4 −0 spec/ci/reporter/test_unit_spec.rb
View
@@ -1,6 +1,7 @@
== 1.3.3
- Use SPEC_OPTS instead of RSPECOPTS (Aslak Hellesøy)
+- Add assertions attribute to individual test cases (Tracker #11563, Andy Sipe)
== 1.3.2
@@ -111,7 +111,7 @@ def builder.trunc!(txt)
end
# Structure used to represent an individual test case. Used to time the test and store the result.
- class TestCase < Struct.new(:name, :time)
+ class TestCase < Struct.new(:name, :time, :assertions)
attr_accessor :failure
# Starts timing the test.
@@ -137,7 +137,7 @@ def error?
# 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) }
+ each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) unless v.nil? || v.to_s.empty?}
builder.testcase(attrs) do
if failure
builder.failure(:type => builder.trunc!(failure.name), :message => builder.trunc!(failure.message)) do
@@ -57,6 +57,7 @@ def started(result)
@last_assertion_count = 0
@current_suite = nil
@unknown_count = 0
+ @result_assertion_count = 0
end
def test_started(name)
@@ -115,6 +116,8 @@ def finish_test(failure = nil)
tc = @current_suite.testcases.last
tc.finish
tc.failure = Failure.new(failure) if failure
+ tc.assertions = @suite_result.assertion_count - @result_assertion_count
+ @result_assertion_count = @suite_result.assertion_count
end
end
end
@@ -47,9 +47,12 @@
@suites.first.name.should == "TestCaseClass"
@suites.first.testcases.length.should == 1
@suites.first.testcases.first.name.should == "test_one"
+ @suites.first.testcases.first.assertions.should == 7
+
@suites.last.name.should == "AnotherTestCaseClass"
@suites.last.testcases.length.should == 1
@suites.last.testcases.first.name.should == "test_two"
+ @suites.last.testcases.first.assertions.should == 0
end
it "should record assertion counts during test run" do
@@ -62,6 +65,7 @@
@testunit.finished(10)
@suite.assertions.should == 7
+ @suite.testcases.last.assertions.should == 7
end
it "should add failures to testcases when encountering a fault" do

0 comments on commit a68606b

Please sign in to comment.