amfranz-ci_reporter 1.6.2

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.
@@ -0,0 +1,151 @@
1
+ # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
+ require 'rexml/document'
7
+
8
+ describe "A TestSuite" do
9
+ before(:each) do
10
+ @suite = CI::Reporter::TestSuite.new("example suite")
11
+ end
12
+
13
+ it "should collect timings when start and finish are invoked in sequence" do
14
+ @suite.start
15
+ @suite.finish
16
+ @suite.time.should >= 0
17
+ end
18
+
19
+ it "should aggregate tests" do
20
+ @suite.start
21
+ @suite.testcases << CI::Reporter::TestCase.new("example test")
22
+ @suite.finish
23
+ @suite.tests.should == 1
24
+ end
25
+
26
+ it "should stringify the name for cases when the object passed in is not a string" do
27
+ name = Object.new
28
+ def name.to_s; "object name"; end
29
+ CI::Reporter::TestSuite.new(name).name.should == "object name"
30
+ end
31
+
32
+ it "should indicate number of failures and errors" do
33
+ failure = mock("failure")
34
+ failure.stub!(:failure?).and_return true
35
+ failure.stub!(:error?).and_return false
36
+
37
+ error = mock("error")
38
+ error.stub!(:failure?).and_return false
39
+ error.stub!(:error?).and_return true
40
+
41
+ @suite.start
42
+ @suite.testcases << CI::Reporter::TestCase.new("example test")
43
+ @suite.testcases << CI::Reporter::TestCase.new("failure test")
44
+ @suite.testcases.last.failures << failure
45
+ @suite.testcases << CI::Reporter::TestCase.new("error test")
46
+ @suite.testcases.last.failures << error
47
+ @suite.finish
48
+ @suite.tests.should == 3
49
+ @suite.failures.should == 1
50
+ @suite.errors.should == 1
51
+ end
52
+ end
53
+
54
+ describe "TestSuite xml" do
55
+ before(:each) do
56
+ @suite = CI::Reporter::TestSuite.new("example suite")
57
+ @suite.assertions = 11
58
+ begin
59
+ raise StandardError, "an exception occurred"
60
+ rescue => e
61
+ @exception = e
62
+ end
63
+ end
64
+
65
+ it "should contain Ant/JUnit-formatted description of entire suite" do
66
+ failure = mock("failure")
67
+ failure.stub!(:failure?).and_return true
68
+ failure.stub!(:error?).and_return false
69
+ failure.stub!(:name).and_return "failure"
70
+ failure.stub!(:message).and_return "There was a failure"
71
+ failure.stub!(:location).and_return @exception.backtrace.join("\n")
72
+
73
+ error = mock("error")
74
+ error.stub!(:failure?).and_return false
75
+ error.stub!(:error?).and_return true
76
+ error.stub!(:name).and_return "error"
77
+ error.stub!(:message).and_return "There was a error"
78
+ error.stub!(:location).and_return @exception.backtrace.join("\n")
79
+
80
+ @suite.start
81
+ @suite.testcases << CI::Reporter::TestCase.new("example test")
82
+ @suite.testcases << CI::Reporter::TestCase.new("skipped test").tap {|tc| tc.skipped = true }
83
+ @suite.testcases << CI::Reporter::TestCase.new("failure test")
84
+ @suite.testcases.last.failures << failure
85
+ @suite.testcases << CI::Reporter::TestCase.new("error test")
86
+ @suite.testcases.last.failures << error
87
+ @suite.finish
88
+
89
+ xml = @suite.to_xml
90
+ doc = REXML::Document.new(xml)
91
+ testsuite = doc.root.elements.to_a("/testsuite")
92
+ testsuite.length.should == 1
93
+ testsuite = testsuite.first
94
+ testsuite.attributes["name"].should == "example suite"
95
+ testsuite.attributes["assertions"].should == "11"
96
+
97
+ testcases = testsuite.elements.to_a("testcase")
98
+ testcases.length.should == 4
99
+ end
100
+
101
+ it "should contain full exception type and message in location element" do
102
+ failure = mock("failure")
103
+ failure.stub!(:failure?).and_return true
104
+ failure.stub!(:error?).and_return false
105
+ failure.stub!(:name).and_return "failure"
106
+ failure.stub!(:message).and_return "There was a failure"
107
+ failure.stub!(:location).and_return @exception.backtrace.join("\n")
108
+
109
+ @suite.start
110
+ @suite.testcases << CI::Reporter::TestCase.new("example test")
111
+ @suite.testcases << CI::Reporter::TestCase.new("failure test")
112
+ @suite.testcases.last.failures << failure
113
+ @suite.finish
114
+
115
+ xml = @suite.to_xml
116
+ doc = REXML::Document.new(xml)
117
+ elem = doc.root.elements.to_a("/testsuite/testcase[@name='failure test']/failure").first
118
+ location = elem.texts.join
119
+ location.should =~ Regexp.new(failure.message)
120
+ location.should =~ Regexp.new(failure.name)
121
+ end
122
+
123
+ it "should filter attributes properly for invalid characters" do
124
+ failure = mock("failure")
125
+ failure.stub!(:failure?).and_return true
126
+ failure.stub!(:error?).and_return false
127
+ failure.stub!(:name).and_return "failure"
128
+ failure.stub!(:message).and_return "There was a <failure>\nReason: blah"
129
+ failure.stub!(:location).and_return @exception.backtrace.join("\n")
130
+
131
+ @suite.start
132
+ @suite.testcases << CI::Reporter::TestCase.new("failure test")
133
+ @suite.testcases.last.failures << failure
134
+ @suite.finish
135
+
136
+ xml = @suite.to_xml
137
+ xml.should =~ %r/message="There was a &lt;failure&gt;\.\.\."/
138
+ end
139
+ end
140
+
141
+ describe "A TestCase" do
142
+ before(:each) do
143
+ @tc = CI::Reporter::TestCase.new("example test")
144
+ end
145
+
146
+ it "should collect timings when start and finish are invoked in sequence" do
147
+ @tc.start
148
+ @tc.finish
149
+ @tc.time.should >= 0
150
+ end
151
+ end
@@ -0,0 +1,152 @@
1
+ # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ require File.dirname(__FILE__) + "/../../spec_helper.rb"
6
+
7
+ describe "The TestUnit reporter" do
8
+ before(:each) do
9
+ @report_mgr = mock("report manager")
10
+ @testunit = CI::Reporter::TestUnit.new(nil, @report_mgr)
11
+ @result = mock("result")
12
+ @result.stub!(:assertion_count).and_return(7)
13
+ end
14
+
15
+ it "should build suites based on adjacent tests with the same class name" do
16
+ @suite = nil
17
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
18
+
19
+ @testunit.started(@result)
20
+ @testunit.test_started("test_one(TestCaseClass)")
21
+ @testunit.test_finished("test_one(TestCaseClass)")
22
+ @testunit.test_started("test_two(TestCaseClass)")
23
+ @testunit.test_finished("test_two(TestCaseClass)")
24
+ @testunit.finished(10)
25
+
26
+ @suite.name.should == "TestCaseClass"
27
+ @suite.testcases.length.should == 2
28
+ @suite.testcases.first.name.should == "test_one"
29
+ @suite.testcases.first.should_not be_failure
30
+ @suite.testcases.first.should_not be_error
31
+ @suite.testcases.last.name.should == "test_two"
32
+ @suite.testcases.last.should_not be_failure
33
+ @suite.testcases.last.should_not be_error
34
+ end
35
+
36
+ it "should build two suites when encountering different class names" do
37
+ @suites = []
38
+ @report_mgr.should_receive(:write_report).twice.and_return {|suite| @suites << suite }
39
+
40
+ @testunit.started(@result)
41
+ @testunit.test_started("test_one(TestCaseClass)")
42
+ @testunit.test_finished("test_one(TestCaseClass)")
43
+ @testunit.test_started("test_two(AnotherTestCaseClass)")
44
+ @testunit.test_finished("test_two(AnotherTestCaseClass)")
45
+ @testunit.finished(10)
46
+
47
+ @suites.first.name.should == "TestCaseClass"
48
+ @suites.first.testcases.length.should == 1
49
+ @suites.first.testcases.first.name.should == "test_one"
50
+ @suites.first.testcases.first.assertions.should == 7
51
+
52
+ @suites.last.name.should == "AnotherTestCaseClass"
53
+ @suites.last.testcases.length.should == 1
54
+ @suites.last.testcases.first.name.should == "test_two"
55
+ @suites.last.testcases.first.assertions.should == 0
56
+ end
57
+
58
+ it "should record assertion counts during test run" do
59
+ @suite = nil
60
+ @report_mgr.should_receive(:write_report).and_return {|suite| @suite = suite }
61
+
62
+ @testunit.started(@result)
63
+ @testunit.test_started("test_one(TestCaseClass)")
64
+ @testunit.test_finished("test_one(TestCaseClass)")
65
+ @testunit.finished(10)
66
+
67
+ @suite.assertions.should == 7
68
+ @suite.testcases.last.assertions.should == 7
69
+ end
70
+
71
+ it "should add failures to testcases when encountering a fault" do
72
+ @failure = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
73
+
74
+ @suite = nil
75
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
76
+
77
+ @testunit.started(@result)
78
+ @testunit.test_started("test_one(TestCaseClass)")
79
+ @testunit.fault(@failure)
80
+ @testunit.test_finished("test_one(TestCaseClass)")
81
+ @testunit.finished(10)
82
+
83
+ @suite.name.should == "TestCaseClass"
84
+ @suite.testcases.length.should == 1
85
+ @suite.testcases.first.name.should == "test_one"
86
+ @suite.testcases.first.should be_failure
87
+ end
88
+
89
+ it "should add errors to testcases when encountering a fault" do
90
+ begin
91
+ raise StandardError, "error"
92
+ rescue => e
93
+ @error = Test::Unit::Error.new("test_two(TestCaseClass)", e)
94
+ end
95
+
96
+ @suite = nil
97
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
98
+
99
+ @testunit.started(@result)
100
+ @testunit.test_started("test_one(TestCaseClass)")
101
+ @testunit.test_finished("test_one(TestCaseClass)")
102
+ @testunit.test_started("test_two(TestCaseClass)")
103
+ @testunit.fault(@error)
104
+ @testunit.test_finished("test_two(TestCaseClass)")
105
+ @testunit.finished(10)
106
+
107
+ @suite.name.should == "TestCaseClass"
108
+ @suite.testcases.length.should == 2
109
+ @suite.testcases.first.name.should == "test_one"
110
+ @suite.testcases.first.should_not be_failure
111
+ @suite.testcases.first.should_not be_error
112
+ @suite.testcases.last.name.should == "test_two"
113
+ @suite.testcases.last.should_not be_failure
114
+ @suite.testcases.last.should be_error
115
+ end
116
+
117
+ it "should add multiple failures to a testcase" do
118
+ @failure1 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
119
+ @failure2 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:12", "it failed again in teardown")
120
+
121
+ @suite = nil
122
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
123
+
124
+ @testunit.started(@result)
125
+ @testunit.test_started("test_one(TestCaseClass)")
126
+ @testunit.fault(@failure1)
127
+ @testunit.fault(@failure2)
128
+ @testunit.test_finished("test_one(TestCaseClass)")
129
+ @testunit.finished(10)
130
+
131
+ @suite.name.should == "TestCaseClass"
132
+ @suite.testcases.length.should == 1
133
+ @suite.testcases.first.name.should == "test_one"
134
+ @suite.testcases.first.should be_failure
135
+ @suite.testcases.first.failures.size.should == 2
136
+ @suite.failures.should == 2
137
+ end
138
+
139
+ it "should count test case names that don't conform to the standard pattern" do
140
+ @suite = nil
141
+ @report_mgr.should_receive(:write_report).once.and_return {|suite| @suite = suite }
142
+
143
+ @testunit.started(@result)
144
+ @testunit.test_started("some unknown test")
145
+ @testunit.test_finished("some unknown test")
146
+ @testunit.finished(10)
147
+
148
+ @suite.name.should == "unknown-1"
149
+ @suite.testcases.length.should == 1
150
+ @suite.testcases.first.name.should == "some unknown test"
151
+ end
152
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ require 'rubygems'
6
+ gem 'rspec'
7
+ require 'spec'
8
+
9
+ unless defined?(CI_REPORTER_LIB)
10
+ CI_REPORTER_LIB = File.expand_path(File.dirname(__FILE__) + "/../lib")
11
+ $: << CI_REPORTER_LIB
12
+ end
13
+
14
+ require 'ci/reporter/core'
15
+ require 'ci/reporter/test_unit'
16
+ require 'ci/reporter/rspec'
17
+
18
+ REPORTS_DIR = File.dirname(__FILE__) + "/reports" unless defined?(REPORTS_DIR)
@@ -0,0 +1,14 @@
1
+ # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+ #
5
+ # Use this stub rakefile as a wrapper around a regular Rakefile. Run in the
6
+ # same directory as the real Rakefile.
7
+ #
8
+ # rake -f /path/to/ci_reporter/lib/ci/reporter/rake/stub.rake ci:setup:rspec default
9
+ #
10
+
11
+ load File.dirname(__FILE__) + '/lib/ci/reporter/rake/rspec.rb'
12
+ load File.dirname(__FILE__) + '/lib/ci/reporter/rake/cucumber.rb'
13
+ load File.dirname(__FILE__) + '/lib/ci/reporter/rake/test_unit.rb'
14
+ load 'Rakefile'
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2006-2010 Nick Sieger <nicksieger@gmail.com>
2
+ # See the file LICENSE.txt included with the distribution for
3
+ # software license details.
4
+
5
+ begin
6
+ gem 'ci_reporter'
7
+ rescue Gem::LoadError
8
+ $: << File.dirname(__FILE__) + "/../lib"
9
+ end
10
+ require 'ci/reporter/rake/rspec'
11
+ require 'ci/reporter/rake/cucumber'
12
+ require 'ci/reporter/rake/test_unit'
13
+
14
+ namespace :ci do
15
+ task :setup_rspec => "ci:setup:rspec"
16
+ task :setup_cucumber => "ci:setup:cucumber"
17
+ task :setup_testunit => "ci:setup:testunit"
18
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amfranz-ci_reporter
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 6
9
+ - 2
10
+ version: 1.6.2
11
+ platform: ruby
12
+ authors:
13
+ - Nick Sieger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-15 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: builder
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 1
33
+ - 2
34
+ version: 2.1.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: CI::Reporter is an add-on to Test::Unit, RSpec and Cucumber that allows you to generate XML reports of your test, spec and/or feature runs. The resulting files can be read by a continuous integration system that understands Ant's JUnit report XML format, thus allowing your CI system to track test/spec successes and failures.
38
+ email: nick@nicksieger.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - History.txt
45
+ - Manifest.txt
46
+ - README.txt
47
+ - LICENSE.txt
48
+ files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - README.txt
52
+ - LICENSE.txt
53
+ - Rakefile
54
+ - stub.rake
55
+ - lib/ci/reporter/rake/test_unit.rb
56
+ - lib/ci/reporter/rake/rspec.rb
57
+ - lib/ci/reporter/rake/rspec_loader.rb
58
+ - lib/ci/reporter/rake/cucumber_loader.rb
59
+ - lib/ci/reporter/rake/cucumber.rb
60
+ - lib/ci/reporter/rake/test_unit_loader.rb
61
+ - lib/ci/reporter/core.rb
62
+ - lib/ci/reporter/test_suite.rb
63
+ - lib/ci/reporter/test_unit.rb
64
+ - lib/ci/reporter/rspec.rb
65
+ - lib/ci/reporter/version.rb
66
+ - lib/ci/reporter/cucumber.rb
67
+ - lib/ci/reporter/report_manager.rb
68
+ - spec/spec_helper.rb
69
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
70
+ - spec/ci/reporter/rspec_spec.rb
71
+ - spec/ci/reporter/test_unit_spec.rb
72
+ - spec/ci/reporter/test_suite_spec.rb
73
+ - spec/ci/reporter/output_capture_spec.rb
74
+ - spec/ci/reporter/report_manager_spec.rb
75
+ - spec/ci/reporter/cucumber_spec.rb
76
+ - tasks/ci_reporter.rake
77
+ has_rdoc: true
78
+ homepage: http://caldersphere.rubyforge.org/ci_reporter
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --main
84
+ - README.txt
85
+ - -SHN
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ requirements: []
107
+
108
+ rubyforge_project: caldersphere
109
+ rubygems_version: 1.3.7
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: CI::Reporter allows you to generate reams of XML for use with continuous integration systems.
113
+ test_files:
114
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
115
+ - spec/ci/reporter/rspec_spec.rb
116
+ - spec/ci/reporter/test_unit_spec.rb
117
+ - spec/ci/reporter/test_suite_spec.rb
118
+ - spec/ci/reporter/output_capture_spec.rb
119
+ - spec/ci/reporter/report_manager_spec.rb
120
+ - spec/ci/reporter/cucumber_spec.rb