ds-ci_reporter_test_unit 1.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.
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/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0
4
+ - 2.1
5
+ - jruby
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ ## 1.0.1 (2015-05-26)
2
+
3
+ Updated gemspec with TestUnit 3 compat.
4
+
5
+ ## 1.0.0 (2014-07-24)
6
+
7
+ The first release after being separated from `ci_reporter`.
8
+
9
+ ### Changes
10
+
11
+ Only the gem version of `Test::Unit` is supported.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ci_reporter_test_unit.gemspec
4
+ gemspec
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,58 @@
1
+ # CI::Reporter::TestUnit
2
+
3
+ Connects [Test::Unit][tu] to [CI::Reporter][ci], and then to your CI
4
+ system.
5
+
6
+ [![Gem Version](https://badge.fury.io/rb/ci_reporter_test_unit.svg)](http://badge.fury.io/rb/ci_reporter_test_unit)
7
+ [![Build Status](https://travis-ci.org/ci-reporter/ci_reporter_test_unit.svg?branch=master)](https://travis-ci.org/ci-reporter/ci_reporter_test_unit)
8
+ [![Dependency Status](https://gemnasium.com/ci-reporter/ci_reporter_test_unit.svg)](https://gemnasium.com/ci-reporter/ci_reporter_test_unit)
9
+ [![Code Climate](https://codeclimate.com/github/ci-reporter/ci_reporter_test_unit.png)](https://codeclimate.com/github/ci-reporter/ci_reporter_test_unit)
10
+
11
+ [tu]: http://www.ruby-doc.org/stdlib-2.1.2/libdoc/test/unit/rdoc/Test/Unit.html
12
+ [ci]: https://github.com/ci-reporter/ci_reporter
13
+
14
+ ## Supported versions
15
+
16
+ The latest release of Test::Unit 2.5 is supported.
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'ci_reporter_test_unit'
24
+ ```
25
+
26
+ And then install it:
27
+
28
+ ```
29
+ $ bundle
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ Require the reporter in your Rakefile, and ensure that
35
+ `ci:setup:testunit` is a dependency of your Test::Unit task:
36
+
37
+ ```ruby
38
+ require 'ci/reporter/rake/test_unit'
39
+
40
+ # ...
41
+ # Rake code that creates a task called `:testunit`
42
+ # ...
43
+
44
+ task :testunit => 'ci:setup:testunit'
45
+ ```
46
+
47
+ ### Advanced usage
48
+
49
+ Refer to the shared [documentation][ci] for details on setting up
50
+ CI::Reporter.
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it ( https://github.com/ci-reporter/ci_reporter_test_unit/fork )
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+ require 'ci/reporter/test_utils/rake'
3
+ include CI::Reporter::TestUtils::Rake
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,55 @@
1
+ require 'rexml/document'
2
+ require 'ci/reporter/test_utils/accessor'
3
+ require 'ci/reporter/test_utils/shared_examples'
4
+ require 'rspec/collection_matchers'
5
+
6
+ REPORTS_DIR = File.dirname(__FILE__) + '/reports'
7
+
8
+ describe "Test::Unit acceptance" do
9
+ include CI::Reporter::TestUtils::SharedExamples
10
+ Accessor = CI::Reporter::TestUtils::Accessor
11
+
12
+ let(:report_path1) { File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestOne.xml') }
13
+ let(:report_path2) { File.join(REPORTS_DIR, 'TEST-TestUnitExampleTestTwo.xml') }
14
+
15
+ context "the first example" do
16
+ subject(:result) { Accessor.new(load_xml_result(report_path1)) }
17
+
18
+ it { is_expected.to have(1).errors }
19
+ it { is_expected.to have(1).failures }
20
+ it { is_expected.to have(1).testcases }
21
+
22
+ describe "the assertion count" do
23
+ subject { result.assertions_count }
24
+ it { is_expected.to eql 1 }
25
+ end
26
+
27
+ it "captures the STDOUT" do
28
+ expect(result.system_out).to eql "Some <![CDATA[on stdout]]>"
29
+ end
30
+
31
+ it_behaves_like "a report with consistent attribute counts"
32
+ end
33
+
34
+ context "the second example" do
35
+ subject(:result) { Accessor.new(load_xml_result(report_path2)) }
36
+
37
+ it { is_expected.to have(0).errors }
38
+ it { is_expected.to have(0).failures }
39
+ it { is_expected.to have(1).testcases }
40
+
41
+ describe "the assertion count" do
42
+ subject { result.assertions_count }
43
+ it { is_expected.to eql 1 }
44
+ end
45
+
46
+ it_behaves_like "a report with consistent attribute counts"
47
+ it_behaves_like "nothing was output"
48
+ end
49
+
50
+ def load_xml_result(path)
51
+ File.open(path) do |f|
52
+ REXML::Document.new(f)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,28 @@
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 = "ds-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{NOTE: This is a fork of ci-reporter/ci_reporter_test_unit}
12
+ spec.homepage = "https://github.com/DanielSe/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", "~> 3.0"
21
+ spec.add_dependency "ci_reporter", "~> 2.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "rspec-collection_matchers"
27
+ spec.add_development_dependency "ci_reporter_test_utils"
28
+ 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,7 @@
1
+ module CI
2
+ module Reporter
3
+ module TestUnitVersion
4
+ VERSION = "1.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + "/../../../spec_helper.rb"
2
+ require 'rake'
3
+ require 'ci/reporter/test_utils/unit'
4
+
5
+ describe "ci_reporter ci:setup:testunit task" do
6
+ include CI::Reporter::TestUtils::Unit
7
+
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
@@ -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,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ds-ci_reporter_test_unit
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nick Sieger
9
+ - Jake Goulding
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-05-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: test-unit
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '3.0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: ci_reporter
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '2.0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '1.6'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rake
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: rspec
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: '3.0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '3.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec-collection_matchers
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ci_reporter_test_utils
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ description:
128
+ email:
129
+ - nick@nicksieger.com
130
+ - jake.goulding@gmail.com
131
+ executables: []
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - .gitignore
136
+ - .travis.yml
137
+ - CHANGELOG.md
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - acceptance/.gitignore
143
+ - acceptance/test_unit_example_test.rb
144
+ - acceptance/verification_spec.rb
145
+ - ci_reporter_test_unit.gemspec
146
+ - lib/ci/reporter/rake/test_unit.rb
147
+ - lib/ci/reporter/rake/test_unit_loader.rb
148
+ - lib/ci/reporter/test_unit.rb
149
+ - lib/ci/reporter/test_unit/version.rb
150
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
151
+ - spec/ci/reporter/test_unit_spec.rb
152
+ - spec/spec_helper.rb
153
+ homepage: https://github.com/DanielSe/ci_reporter_test_unit
154
+ licenses:
155
+ - MIT
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ none: false
168
+ requirements:
169
+ - - ! '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 1.8.23.2
175
+ signing_key:
176
+ specification_version: 3
177
+ summary: ! 'NOTE: This is a fork of ci-reporter/ci_reporter_test_unit'
178
+ test_files:
179
+ - acceptance/.gitignore
180
+ - acceptance/test_unit_example_test.rb
181
+ - acceptance/verification_spec.rb
182
+ - spec/ci/reporter/rake/rake_tasks_spec.rb
183
+ - spec/ci/reporter/test_unit_spec.rb
184
+ - spec/spec_helper.rb