ci_reporter 1.0 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/README.txt +3 -1
- data/Rakefile +1 -1
- data/lib/ci/reporter/test_suite.rb +2 -2
- data/lib/ci/reporter/test_unit.rb +4 -0
- data/spec/ci/reporter/test_suite_spec.rb +5 -2
- data/spec/ci/reporter/test_unit_spec.rb +17 -3
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.1
|
2
|
+
|
3
|
+
- Add +assertions+ attribute to the +testsuite+ element that will contain per-suite assertion counts when used with Test::Unit. Not useful with applications that read Ant/JUnit XML, but custom applications may wish to access it.
|
4
|
+
|
1
5
|
== 1.0
|
2
6
|
|
3
7
|
Initial Release.
|
data/README.txt
CHANGED
@@ -33,9 +33,11 @@ CI::Reporter works best with projects that use a +Rakefile+ along with the stand
|
|
33
33
|
|
34
34
|
rake ci:setup:testunit test
|
35
35
|
|
36
|
+
Report files are written, by default, to the <code>test/reports</code> or <code>spec/reports</code> subdirectory of your project. If you wish to customize the location, simply set the environment variable CI_REPORTS (either in the environment, on the Rake command line, or in your Rakefile) to the location where they should go.
|
37
|
+
|
36
38
|
== Advanced Usage
|
37
39
|
|
38
|
-
If for some reason you can't use the above technique to inject CI::Reporter, you'll have to do one of these:
|
40
|
+
If for some reason you can't use the above technique to inject CI::Reporter (e.g., you're not using Rake), you'll have to do one of these:
|
39
41
|
|
40
42
|
1. If you're using <code>Test::Unit</code>, ensure the <code>ci/reporter/rake/test_unit_loader.rb</code> file is loaded or required at some point before the tests are run.
|
41
43
|
2. If you're using +RSpec+, you'll need to pass the following arguments to the +spec+ command:
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'hoe'
|
|
4
4
|
MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt", "Rakefile",
|
5
5
|
"lib/**/*.rb", "spec/**/*.rb", "tasks/**/*.rake"]
|
6
6
|
|
7
|
-
Hoe.new("ci_reporter", "1.
|
7
|
+
Hoe.new("ci_reporter", "1.1") do |p|
|
8
8
|
p.rubyforge_name = "caldersphere"
|
9
9
|
p.url = "http://caldersphere.rubyforge.org/ci_reporter"
|
10
10
|
p.author = "Nick Sieger"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module CI
|
2
2
|
module Reporter
|
3
3
|
# Basic structure representing the running of a test suite. Used to time tests and store results.
|
4
|
-
class TestSuite < Struct.new(:name, :tests, :time, :failures, :errors)
|
4
|
+
class TestSuite < Struct.new(:name, :tests, :time, :failures, :errors, :assertions)
|
5
5
|
attr_accessor :testcases
|
6
6
|
def initialize(name)
|
7
7
|
super
|
@@ -53,7 +53,7 @@ module CI
|
|
53
53
|
end
|
54
54
|
builder.instruct!
|
55
55
|
attrs = {}
|
56
|
-
each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) }
|
56
|
+
each_pair {|k,v| attrs[k] = builder.trunc!(v.to_s) unless v.nil? || v.to_s.empty? }
|
57
57
|
builder.testsuite(attrs) do
|
58
58
|
@testcases.each do |tc|
|
59
59
|
tc.to_xml(builder)
|
@@ -49,6 +49,8 @@ module CI
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def started(result)
|
52
|
+
@suite_result = result
|
53
|
+
@last_assertion_count = 0
|
52
54
|
@current_suite = nil
|
53
55
|
@unknown_count = 0
|
54
56
|
end
|
@@ -93,6 +95,8 @@ module CI
|
|
93
95
|
def finish_suite
|
94
96
|
if @current_suite
|
95
97
|
@current_suite.finish
|
98
|
+
@current_suite.assertions = @suite_result.assertion_count - @last_assertion_count
|
99
|
+
@last_assertion_count = @suite_result.assertion_count
|
96
100
|
@report_manager.write_report(@current_suite)
|
97
101
|
end
|
98
102
|
end
|
@@ -45,6 +45,7 @@ end
|
|
45
45
|
context "TestSuite xml" do
|
46
46
|
setup do
|
47
47
|
@suite = CI::Reporter::TestSuite.new("example suite")
|
48
|
+
@suite.assertions = 11
|
48
49
|
begin
|
49
50
|
raise StandardError, "an exception occurred"
|
50
51
|
rescue => e
|
@@ -77,11 +78,13 @@ context "TestSuite xml" do
|
|
77
78
|
|
78
79
|
xml = @suite.to_xml
|
79
80
|
doc = REXML::Document.new(xml)
|
80
|
-
testsuite = doc.root.elements.to_a(
|
81
|
+
testsuite = doc.root.elements.to_a("/testsuite")
|
81
82
|
testsuite.length.should == 1
|
82
83
|
testsuite = testsuite.first
|
84
|
+
testsuite.attributes["name"].should == "example suite"
|
85
|
+
testsuite.attributes["assertions"].should == "11"
|
83
86
|
|
84
|
-
testcases = testsuite.elements.to_a(
|
87
|
+
testcases = testsuite.elements.to_a("testcase")
|
85
88
|
testcases.length.should == 3
|
86
89
|
end
|
87
90
|
|
@@ -4,13 +4,15 @@ context "The TestUnit reporter" do
|
|
4
4
|
setup do
|
5
5
|
@report_mgr = mock("report manager")
|
6
6
|
@testunit = CI::Reporter::TestUnit.new(nil, @report_mgr)
|
7
|
+
@result = mock("result")
|
8
|
+
@result.stub!(:assertion_count).and_return(7)
|
7
9
|
end
|
8
10
|
|
9
11
|
specify "should build suites based on adjacent tests with the same class name" do
|
10
12
|
@suite = nil
|
11
13
|
@report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
|
12
14
|
|
13
|
-
@testunit.started(
|
15
|
+
@testunit.started(@result)
|
14
16
|
@testunit.test_started("test_one(TestCaseClass)")
|
15
17
|
@testunit.test_finished("test_one(TestCaseClass)")
|
16
18
|
@testunit.test_started("test_two(TestCaseClass)")
|
@@ -31,7 +33,7 @@ context "The TestUnit reporter" do
|
|
31
33
|
@suites = []
|
32
34
|
@report_mgr.should_receive(:write_report).twice.and_return {|suite| @suites << suite }
|
33
35
|
|
34
|
-
@testunit.started(
|
36
|
+
@testunit.started(@result)
|
35
37
|
@testunit.test_started("test_one(TestCaseClass)")
|
36
38
|
@testunit.test_finished("test_one(TestCaseClass)")
|
37
39
|
@testunit.test_started("test_two(AnotherTestCaseClass)")
|
@@ -46,6 +48,18 @@ context "The TestUnit reporter" do
|
|
46
48
|
@suites.last.testcases.first.name.should == "test_two"
|
47
49
|
end
|
48
50
|
|
51
|
+
specify "should record assertion counts during test run" do
|
52
|
+
@suite = nil
|
53
|
+
@report_mgr.should_receive(:write_report).and_return {|suite| @suite = suite }
|
54
|
+
|
55
|
+
@testunit.started(@result)
|
56
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
57
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
58
|
+
@testunit.finished(10)
|
59
|
+
|
60
|
+
@suite.assertions.should == 7
|
61
|
+
end
|
62
|
+
|
49
63
|
specify "should add failures to testcases when encountering a fault" do
|
50
64
|
begin
|
51
65
|
raise StandardError, "error"
|
@@ -56,7 +70,7 @@ context "The TestUnit reporter" do
|
|
56
70
|
@suite = nil
|
57
71
|
@report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
|
58
72
|
|
59
|
-
@testunit.started(
|
73
|
+
@testunit.started(@result)
|
60
74
|
@testunit.test_started("test_one(TestCaseClass)")
|
61
75
|
@testunit.test_finished("test_one(TestCaseClass)")
|
62
76
|
@testunit.test_started("test_two(TestCaseClass)")
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: ci_reporter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
7
|
-
date: 2007-
|
6
|
+
version: "1.1"
|
7
|
+
date: 2007-03-15 00:00:00 -05:00
|
8
8
|
summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.
|
9
9
|
require_paths:
|
10
10
|
- lib
|