ci_reporter_test_unit 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +53 -0
- data/Rakefile +31 -0
- data/acceptance/.gitignore +1 -0
- data/acceptance/test_unit_example_test.rb +17 -0
- data/acceptance/verification_spec.rb +38 -0
- data/ci_reporter_test_unit.gemspec +26 -0
- data/lib/ci/reporter/rake/test_unit.rb +11 -0
- data/lib/ci/reporter/rake/test_unit_loader.rb +34 -0
- data/lib/ci/reporter/test_unit.rb +152 -0
- data/lib/ci/reporter/test_unit/version.rb +7 -0
- data/spec/ci/reporter/rake/rake_tasks_spec.rb +32 -0
- data/spec/ci/reporter/test_unit_spec.rb +150 -0
- data/spec/spec_helper.rb +17 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80bd6245decad60a53b37b1b2f5c15ab8facaa15
|
4
|
+
data.tar.gz: 4a82350ea4e1de2dd584dfa06a4fc1b04f2c0c85
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62a8a1c6fa7d6edb3df1b7b0885ad56b5834ec3dda3cd1c6edf07bc6712c44e73c493407a12b5179cccb0c95dd7cf53fd296c295587e75b666fb21ee6bc695f4
|
7
|
+
data.tar.gz: e354b0007748d94c843613c397c9d0b5ec015bb9465f55af2cfdd604ba93aa3febe12ad25d2472caffc313c9a52ae190cff5e3741a5c040724fcd05610d27156
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2006-2014 Nick Sieger <nicksieger@gmail.com>
|
2
|
+
Copyright (c) 2014 The CI Reporter authors
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# CI::Reporter::TestUnit
|
2
|
+
|
3
|
+
Connects [Test::Unit][tu] to [CI::Reporter][ci], and then to your CI
|
4
|
+
system.
|
5
|
+
|
6
|
+
[tu]: http://www.ruby-doc.org/stdlib-2.1.2/libdoc/test/unit/rdoc/Test/Unit.html
|
7
|
+
[ci]: https://github.com/ci-reporter/ci_reporter
|
8
|
+
|
9
|
+
## Supported versions
|
10
|
+
|
11
|
+
The latest release of Test::Unit 2.5 is supported.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'ci_reporter_test_unit'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then install it:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Require the reporter in your Rakefile, and ensure that
|
30
|
+
`ci:setup:testunit` is a dependency of your RSpec task:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'ci/reporter/rake/test_unit'
|
34
|
+
|
35
|
+
# ...
|
36
|
+
# Rake code that creates a task called `:testunit`
|
37
|
+
# ...
|
38
|
+
|
39
|
+
task :testunit => 'ci:setup:testunit'
|
40
|
+
```
|
41
|
+
|
42
|
+
### Advanced usage
|
43
|
+
|
44
|
+
Refer to the shared [documentation][ci] for details on setting up
|
45
|
+
CI::Reporter.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it ( https://github.com/ci-reporter/ci_reporter_test_unit/fork )
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'ci/reporter/internal'
|
3
|
+
include CI::Reporter::Internal
|
4
|
+
|
5
|
+
namespace :generate do
|
6
|
+
task :clean do
|
7
|
+
rm_rf "acceptance/reports"
|
8
|
+
end
|
9
|
+
|
10
|
+
task :test_unit do
|
11
|
+
run_ruby_acceptance "-rci/reporter/rake/test_unit_loader acceptance/test_unit_example_test.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
task :all => [:clean, :test_unit]
|
15
|
+
end
|
16
|
+
|
17
|
+
task :acceptance => "generate:all"
|
18
|
+
|
19
|
+
require 'rspec/core/rake_task'
|
20
|
+
RSpec::Core::RakeTask.new(:acceptance_spec) do |t|
|
21
|
+
t.pattern = FileList['acceptance/verification_spec.rb']
|
22
|
+
t.rspec_opts = "--color"
|
23
|
+
end
|
24
|
+
task :acceptance => :acceptance_spec
|
25
|
+
|
26
|
+
RSpec::Core::RakeTask.new(:unit_spec) do |t|
|
27
|
+
t.pattern = FileList['spec']
|
28
|
+
t.rspec_opts = "--color"
|
29
|
+
end
|
30
|
+
|
31
|
+
task :default => [:unit_spec, :acceptance]
|
@@ -0,0 +1 @@
|
|
1
|
+
reports/
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TestUnitExampleTestOne < Test::Unit::TestCase
|
4
|
+
def test_one
|
5
|
+
puts "Some <![CDATA[on stdout]]>"
|
6
|
+
assert(false, "First failure")
|
7
|
+
end
|
8
|
+
def teardown
|
9
|
+
raise "second failure"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestUnitExampleTestTwo < Test::Unit::TestCase
|
14
|
+
def test_two
|
15
|
+
assert true
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
REPORTS_DIR = File.dirname(__FILE__) + '/reports'
|
4
|
+
|
5
|
+
describe "Test::Unit acceptance" do
|
6
|
+
it "should generate two XML files" do
|
7
|
+
File.exist?(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestOne.xml')).should == true
|
8
|
+
File.exist?(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestTwo.xml')).should == true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have one error and one failure for TestUnitExampleTestOne" do
|
12
|
+
doc = File.open(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestOne.xml')) do |f|
|
13
|
+
REXML::Document.new(f)
|
14
|
+
end
|
15
|
+
doc.root.attributes["errors"].should == "1"
|
16
|
+
doc.root.attributes["failures"].should == "1"
|
17
|
+
doc.root.attributes["assertions"].should == "1"
|
18
|
+
doc.root.attributes["tests"].should == "1"
|
19
|
+
doc.root.elements.to_a("/testsuite/testcase").size.should == 1
|
20
|
+
doc.root.elements.to_a("/testsuite/testcase/error").size.should == 1
|
21
|
+
doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 1
|
22
|
+
doc.root.elements.to_a("/testsuite/system-out").first.texts.inject("") do |c,e|
|
23
|
+
c << e.value; c
|
24
|
+
end.strip.should == "Some <![CDATA[on stdout]]>"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have no errors or failures for TestUnitExampleTestTwo" do
|
28
|
+
doc = File.open(File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestTwo.xml')) do |f|
|
29
|
+
REXML::Document.new(f)
|
30
|
+
end
|
31
|
+
doc.root.attributes["errors"].should == "0"
|
32
|
+
doc.root.attributes["failures"].should == "0"
|
33
|
+
doc.root.attributes["assertions"].should == "1"
|
34
|
+
doc.root.attributes["tests"].should == "1"
|
35
|
+
doc.root.elements.to_a("/testsuite/testcase").size.should == 1
|
36
|
+
doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 0
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ci/reporter/test_unit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ci_reporter_test_unit"
|
8
|
+
spec.version = CI::Reporter::TestUnitVersion::VERSION
|
9
|
+
spec.authors = ["Nick Sieger", "Jake Goulding"]
|
10
|
+
spec.email = ["nick@nicksieger.com", "jake.goulding@gmail.com"]
|
11
|
+
spec.summary = %q{Connects CI::Reporter to Test::Unit}
|
12
|
+
spec.homepage = "https://github.com/ci-reporter/ci_reporter_test_unit"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|acceptance)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "test-unit", "~> 2.5.5"
|
21
|
+
spec.add_dependency "ci_reporter", "2.0.0.alpha1"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.0"
|
26
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'ci/reporter/rake/utils'
|
2
|
+
|
3
|
+
namespace :ci do
|
4
|
+
namespace :setup do
|
5
|
+
task :testunit do
|
6
|
+
rm_rf ENV["CI_REPORTS"] || "test/reports"
|
7
|
+
test_loader = CI::Reporter.maybe_quote_filename "#{File.dirname(__FILE__)}/test_unit_loader.rb"
|
8
|
+
ENV["TESTOPTS"] = "#{ENV["TESTOPTS"]} #{test_loader}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
$: << File.dirname(__FILE__) + "/../../.."
|
2
|
+
require 'ci/reporter/test_unit'
|
3
|
+
|
4
|
+
# Intercepts mediator creation in ruby-test < 2.1
|
5
|
+
module Test #:nodoc:all
|
6
|
+
module Unit
|
7
|
+
module UI
|
8
|
+
module Console
|
9
|
+
class TestRunner
|
10
|
+
undef :create_mediator if instance_methods.map(&:to_s).include?("create_mediator")
|
11
|
+
def create_mediator(suite)
|
12
|
+
# swap in our custom mediator
|
13
|
+
return CI::Reporter::TestUnit.new(suite)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Intercepts mediator creation in ruby-test >= 2.1
|
22
|
+
module Test #:nodoc:all
|
23
|
+
module Unit
|
24
|
+
module UI
|
25
|
+
class TestRunner
|
26
|
+
undef :setup_mediator if instance_methods.map(&:to_s).include?("setup_mediator")
|
27
|
+
def setup_mediator
|
28
|
+
# swap in our custom mediator
|
29
|
+
@mediator = CI::Reporter::TestUnit.new(@suite)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'ci/reporter/core'
|
2
|
+
require 'ci/reporter/test_unit/version'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'test/unit/ui/console/testrunner'
|
5
|
+
|
6
|
+
module CI
|
7
|
+
module Reporter
|
8
|
+
# Factory for constructing either a CI::Reporter::TestUnitFailure or CI::Reporter::TestUnitError depending on the result
|
9
|
+
# of the test.
|
10
|
+
class Failure
|
11
|
+
def self.omission_constant?
|
12
|
+
Test::Unit.const_defined?(:Omission, false)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.notification_constant?
|
16
|
+
Test::Unit.const_defined?(:Notification, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.new(fault)
|
20
|
+
return TestUnitFailure.new(fault) if fault.kind_of?(Test::Unit::Failure)
|
21
|
+
return TestUnitSkipped.new(fault) if omission_constant? &&
|
22
|
+
(fault.kind_of?(Test::Unit::Omission) || fault.kind_of?(Test::Unit::Pending))
|
23
|
+
return TestUnitNotification.new(fault) if notification_constant? &&
|
24
|
+
fault.kind_of?(Test::Unit::Notification)
|
25
|
+
TestUnitError.new(fault)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Wrapper around a <code>Test::Unit</code> error to be used by the test suite to interpret results.
|
30
|
+
class TestUnitError
|
31
|
+
def initialize(fault) @fault = fault end
|
32
|
+
def failure?() false end
|
33
|
+
def error?() true end
|
34
|
+
def name() @fault.exception.class.name end
|
35
|
+
def message() @fault.exception.message end
|
36
|
+
def location() @fault.exception.backtrace.join("\n") end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Wrapper around a <code>Test::Unit</code> failure to be used by the test suite to interpret results.
|
40
|
+
class TestUnitFailure
|
41
|
+
def initialize(fault) @fault = fault end
|
42
|
+
def failure?() true end
|
43
|
+
def error?() false end
|
44
|
+
def name() Test::Unit::AssertionFailedError.name end
|
45
|
+
def message() @fault.message end
|
46
|
+
def location() @fault.location.join("\n") end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Wrapper around a <code>Test::Unit</code> 2.0 omission.
|
50
|
+
class TestUnitSkipped
|
51
|
+
def initialize(fault) @fault = fault end
|
52
|
+
def failure?() false end
|
53
|
+
def error?() false end
|
54
|
+
def name() @fault.class.name end
|
55
|
+
def message() @fault.message end
|
56
|
+
def location() @fault.location.join("\n") end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Wrapper around a <code>Test::Unit</code> 2.0 notification.
|
60
|
+
class TestUnitNotification
|
61
|
+
def initialize(fault) @fault = fault end
|
62
|
+
def failure?() false end
|
63
|
+
def error?() false end
|
64
|
+
def name() @fault.class.name end
|
65
|
+
def message() @fault.message end
|
66
|
+
def location() @fault.location.join("\n") end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Replacement Mediator that adds listeners to capture the results of the <code>Test::Unit</code> runs.
|
70
|
+
class TestUnit < Test::Unit::UI::TestRunnerMediator
|
71
|
+
include TestUnitVersion
|
72
|
+
|
73
|
+
def initialize(suite, report_mgr = nil)
|
74
|
+
super(suite)
|
75
|
+
@report_manager = report_mgr || ReportManager.new("test")
|
76
|
+
add_listener(Test::Unit::UI::TestRunnerMediator::STARTED, &method(:started))
|
77
|
+
add_listener(Test::Unit::TestCase::STARTED, &method(:test_started))
|
78
|
+
add_listener(Test::Unit::TestCase::FINISHED, &method(:test_finished))
|
79
|
+
add_listener(Test::Unit::TestResult::FAULT, &method(:fault))
|
80
|
+
add_listener(Test::Unit::UI::TestRunnerMediator::FINISHED, &method(:finished))
|
81
|
+
end
|
82
|
+
|
83
|
+
def started(result)
|
84
|
+
@suite_result = result
|
85
|
+
@last_assertion_count = 0
|
86
|
+
@current_suite = nil
|
87
|
+
@unknown_count = 0
|
88
|
+
@result_assertion_count = 0
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_started(name)
|
92
|
+
test_name, suite_name = extract_names(name)
|
93
|
+
unless @current_suite && @current_suite.name == suite_name
|
94
|
+
finish_suite
|
95
|
+
start_suite(suite_name)
|
96
|
+
end
|
97
|
+
start_test(test_name)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_finished(name)
|
101
|
+
finish_test
|
102
|
+
end
|
103
|
+
|
104
|
+
def fault(fault)
|
105
|
+
tc = @current_suite.testcases.last
|
106
|
+
tc.failures << Failure.new(fault)
|
107
|
+
end
|
108
|
+
|
109
|
+
def finished(elapsed_time)
|
110
|
+
finish_suite
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
def extract_names(name)
|
115
|
+
match = name.match(/(.*)\(([^)]*)\)/)
|
116
|
+
if match
|
117
|
+
[match[1], match[2]]
|
118
|
+
else
|
119
|
+
@unknown_count += 1
|
120
|
+
[name, "unknown-#{@unknown_count}"]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def start_suite(suite_name)
|
125
|
+
@current_suite = TestSuite.new(suite_name)
|
126
|
+
@current_suite.start
|
127
|
+
end
|
128
|
+
|
129
|
+
def finish_suite
|
130
|
+
if @current_suite
|
131
|
+
@current_suite.finish
|
132
|
+
@current_suite.assertions = @suite_result.assertion_count - @last_assertion_count
|
133
|
+
@last_assertion_count = @suite_result.assertion_count
|
134
|
+
@report_manager.write_report(@current_suite)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def start_test(test_name)
|
139
|
+
tc = TestCase.new(test_name)
|
140
|
+
tc.start
|
141
|
+
@current_suite.testcases << tc
|
142
|
+
end
|
143
|
+
|
144
|
+
def finish_test
|
145
|
+
tc = @current_suite.testcases.last
|
146
|
+
tc.finish
|
147
|
+
tc.assertions = @suite_result.assertion_count - @result_assertion_count
|
148
|
+
@result_assertion_count = @suite_result.assertion_count
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../../spec_helper.rb"
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'ci/reporter/internal'
|
5
|
+
include CI::Reporter::Internal
|
6
|
+
|
7
|
+
describe "ci_reporter ci:setup:testunit task" do
|
8
|
+
before(:each) do
|
9
|
+
@rake = Rake::Application.new
|
10
|
+
Rake.application = @rake
|
11
|
+
load CI_REPORTER_LIB + '/ci/reporter/rake/test_unit.rb'
|
12
|
+
save_env "CI_REPORTS"
|
13
|
+
save_env "TESTOPTS"
|
14
|
+
ENV["CI_REPORTS"] = "some-bogus-nonexistent-directory-that-wont-fail-rm_rf"
|
15
|
+
end
|
16
|
+
after(:each) do
|
17
|
+
restore_env "TESTOPTS"
|
18
|
+
restore_env "CI_REPORTS"
|
19
|
+
Rake.application = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should set ENV['TESTOPTS'] to include test/unit setup file" do
|
23
|
+
@rake["ci:setup:testunit"].invoke
|
24
|
+
ENV["TESTOPTS"].should =~ /test_unit_loader/
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should append to ENV['TESTOPTS'] if it already contains a value" do
|
28
|
+
ENV["TESTOPTS"] = "somevalue".freeze
|
29
|
+
@rake["ci:setup:testunit"].invoke
|
30
|
+
ENV["TESTOPTS"].should =~ /somevalue.*test_unit_loader/
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper.rb"
|
2
|
+
require 'ci/reporter/test_unit'
|
3
|
+
Test::Unit.run = true
|
4
|
+
|
5
|
+
describe "The TestUnit reporter" do
|
6
|
+
before(:each) do
|
7
|
+
@report_mgr = double("report manager")
|
8
|
+
@testunit = CI::Reporter::TestUnit.new(nil, @report_mgr)
|
9
|
+
@result = double("result")
|
10
|
+
@result.stub(:assertion_count).and_return(7)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should build suites based on adjacent tests with the same class name" do
|
14
|
+
@suite = nil
|
15
|
+
@report_mgr.should_receive(:write_report).once {|suite| @suite = suite }
|
16
|
+
|
17
|
+
@testunit.started(@result)
|
18
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
19
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
20
|
+
@testunit.test_started("test_two(TestCaseClass)")
|
21
|
+
@testunit.test_finished("test_two(TestCaseClass)")
|
22
|
+
@testunit.finished(10)
|
23
|
+
|
24
|
+
@suite.name.should == "TestCaseClass"
|
25
|
+
@suite.testcases.length.should == 2
|
26
|
+
@suite.testcases.first.name.should == "test_one"
|
27
|
+
@suite.testcases.first.should_not be_failure
|
28
|
+
@suite.testcases.first.should_not be_error
|
29
|
+
@suite.testcases.last.name.should == "test_two"
|
30
|
+
@suite.testcases.last.should_not be_failure
|
31
|
+
@suite.testcases.last.should_not be_error
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should build two suites when encountering different class names" do
|
35
|
+
@suites = []
|
36
|
+
@report_mgr.should_receive(:write_report).twice {|suite| @suites << suite }
|
37
|
+
|
38
|
+
@testunit.started(@result)
|
39
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
40
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
41
|
+
@testunit.test_started("test_two(AnotherTestCaseClass)")
|
42
|
+
@testunit.test_finished("test_two(AnotherTestCaseClass)")
|
43
|
+
@testunit.finished(10)
|
44
|
+
|
45
|
+
@suites.first.name.should == "TestCaseClass"
|
46
|
+
@suites.first.testcases.length.should == 1
|
47
|
+
@suites.first.testcases.first.name.should == "test_one"
|
48
|
+
@suites.first.testcases.first.assertions.should == 7
|
49
|
+
|
50
|
+
@suites.last.name.should == "AnotherTestCaseClass"
|
51
|
+
@suites.last.testcases.length.should == 1
|
52
|
+
@suites.last.testcases.first.name.should == "test_two"
|
53
|
+
@suites.last.testcases.first.assertions.should == 0
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should record assertion counts during test run" do
|
57
|
+
@suite = nil
|
58
|
+
@report_mgr.should_receive(:write_report) {|suite| @suite = suite }
|
59
|
+
|
60
|
+
@testunit.started(@result)
|
61
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
62
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
63
|
+
@testunit.finished(10)
|
64
|
+
|
65
|
+
@suite.assertions.should == 7
|
66
|
+
@suite.testcases.last.assertions.should == 7
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should add failures to testcases when encountering a fault" do
|
70
|
+
@failure = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
|
71
|
+
|
72
|
+
@suite = nil
|
73
|
+
@report_mgr.should_receive(:write_report).once {|suite| @suite = suite }
|
74
|
+
|
75
|
+
@testunit.started(@result)
|
76
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
77
|
+
@testunit.fault(@failure)
|
78
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
79
|
+
@testunit.finished(10)
|
80
|
+
|
81
|
+
@suite.name.should == "TestCaseClass"
|
82
|
+
@suite.testcases.length.should == 1
|
83
|
+
@suite.testcases.first.name.should == "test_one"
|
84
|
+
@suite.testcases.first.should be_failure
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should add errors to testcases when encountering a fault" do
|
88
|
+
begin
|
89
|
+
raise StandardError, "error"
|
90
|
+
rescue => e
|
91
|
+
@error = Test::Unit::Error.new("test_two(TestCaseClass)", e)
|
92
|
+
end
|
93
|
+
|
94
|
+
@suite = nil
|
95
|
+
@report_mgr.should_receive(:write_report).once {|suite| @suite = suite }
|
96
|
+
|
97
|
+
@testunit.started(@result)
|
98
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
99
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
100
|
+
@testunit.test_started("test_two(TestCaseClass)")
|
101
|
+
@testunit.fault(@error)
|
102
|
+
@testunit.test_finished("test_two(TestCaseClass)")
|
103
|
+
@testunit.finished(10)
|
104
|
+
|
105
|
+
@suite.name.should == "TestCaseClass"
|
106
|
+
@suite.testcases.length.should == 2
|
107
|
+
@suite.testcases.first.name.should == "test_one"
|
108
|
+
@suite.testcases.first.should_not be_failure
|
109
|
+
@suite.testcases.first.should_not be_error
|
110
|
+
@suite.testcases.last.name.should == "test_two"
|
111
|
+
@suite.testcases.last.should_not be_failure
|
112
|
+
@suite.testcases.last.should be_error
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should add multiple failures to a testcase" do
|
116
|
+
@failure1 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:10", "it failed")
|
117
|
+
@failure2 = Test::Unit::Failure.new("test_one(TestCaseClass)", "somewhere:12", "it failed again in teardown")
|
118
|
+
|
119
|
+
@suite = nil
|
120
|
+
@report_mgr.should_receive(:write_report).once {|suite| @suite = suite }
|
121
|
+
|
122
|
+
@testunit.started(@result)
|
123
|
+
@testunit.test_started("test_one(TestCaseClass)")
|
124
|
+
@testunit.fault(@failure1)
|
125
|
+
@testunit.fault(@failure2)
|
126
|
+
@testunit.test_finished("test_one(TestCaseClass)")
|
127
|
+
@testunit.finished(10)
|
128
|
+
|
129
|
+
@suite.name.should == "TestCaseClass"
|
130
|
+
@suite.testcases.length.should == 1
|
131
|
+
@suite.testcases.first.name.should == "test_one"
|
132
|
+
@suite.testcases.first.should be_failure
|
133
|
+
@suite.testcases.first.failures.size.should == 2
|
134
|
+
@suite.failures.should == 2
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should count test case names that don't conform to the standard pattern" do
|
138
|
+
@suite = nil
|
139
|
+
@report_mgr.should_receive(:write_report).once {|suite| @suite = suite }
|
140
|
+
|
141
|
+
@testunit.started(@result)
|
142
|
+
@testunit.test_started("some unknown test")
|
143
|
+
@testunit.test_finished("some unknown test")
|
144
|
+
@testunit.finished(10)
|
145
|
+
|
146
|
+
@suite.name.should == "unknown-1"
|
147
|
+
@suite.testcases.length.should == 1
|
148
|
+
@suite.testcases.first.name.should == "some unknown test"
|
149
|
+
end
|
150
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
begin
|
3
|
+
require 'rspec'
|
4
|
+
rescue LoadError
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'rspec/autorun' if $0 =~ /rcov$/
|
9
|
+
|
10
|
+
unless defined?(CI_REPORTER_LIB)
|
11
|
+
CI_REPORTER_LIB = File.expand_path(File.dirname(__FILE__) + "/../lib")
|
12
|
+
$: << CI_REPORTER_LIB
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'ci/reporter/core'
|
16
|
+
|
17
|
+
REPORTS_DIR = File.dirname(__FILE__) + "/reports" unless defined?(REPORTS_DIR)
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ci_reporter_test_unit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Sieger
|
8
|
+
- Jake Goulding
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: test-unit
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.5.5
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.5.5
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: ci_reporter
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.0.0.alpha1
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.0.0.alpha1
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.6'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.6'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.0'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- nick@nicksieger.com
|
87
|
+
- jake.goulding@gmail.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- acceptance/.gitignore
|
99
|
+
- acceptance/test_unit_example_test.rb
|
100
|
+
- acceptance/verification_spec.rb
|
101
|
+
- ci_reporter_test_unit.gemspec
|
102
|
+
- lib/ci/reporter/rake/test_unit.rb
|
103
|
+
- lib/ci/reporter/rake/test_unit_loader.rb
|
104
|
+
- lib/ci/reporter/test_unit.rb
|
105
|
+
- lib/ci/reporter/test_unit/version.rb
|
106
|
+
- spec/ci/reporter/rake/rake_tasks_spec.rb
|
107
|
+
- spec/ci/reporter/test_unit_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
homepage: https://github.com/ci-reporter/ci_reporter_test_unit
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.2.2
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Connects CI::Reporter to Test::Unit
|
133
|
+
test_files:
|
134
|
+
- acceptance/.gitignore
|
135
|
+
- acceptance/test_unit_example_test.rb
|
136
|
+
- acceptance/verification_spec.rb
|
137
|
+
- spec/ci/reporter/rake/rake_tasks_spec.rb
|
138
|
+
- spec/ci/reporter/test_unit_spec.rb
|
139
|
+
- spec/spec_helper.rb
|