test-unit-runner-junitxml 0.1.0 → 0.3.0
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 +5 -5
- data/.github/workflows/test.yml +33 -0
- data/.gitignore +3 -0
- data/README.ja.md +58 -0
- data/README.md +55 -2
- data/Rakefile +6 -5
- data/lib/test/unit/runner/junitxml/version.rb +1 -1
- data/lib/test/unit/runner/junitxml.rb +4 -0
- data/lib/test/unit/ui/junitxml/testrunner.rb +27 -6
- data/lib/test/unit/ui/junitxml/xml.erb +21 -28
- data/test-unit-runner-junitxml.gemspec +5 -5
- metadata +36 -22
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dae7dcbf6a1e92a1f31dae3d428eb815a08a36374096a5936ff38eae7cd0cb7b
|
4
|
+
data.tar.gz: bffb5ed616dd1df0c7601a938839ce1cfaceaf2fdad1908cea1b506963ea11d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb431e6eb84b3baa5f2c834ec20376e86532747bdcf5dbe26d05748cfd3bc6d03bede34851cccf1baac239a1eb2f7d9169510560907ab5024d46ed43e4ad8784
|
7
|
+
data.tar.gz: e6f8db833e78bd128f6025dd631020e495a3511bf2ee9984ca050e7ef8bb4427289c7fdabe78a52c54af5fc491be6cc06390ea6414ff27e6cce8f72ab523b2a1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Test
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
schedule:
|
8
|
+
- cron: '34 18 * * *'
|
9
|
+
jobs:
|
10
|
+
rake-test:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
15
|
+
ruby: [head, 3.1, 3.0, 2.7, 2.6, jruby, truffleruby]
|
16
|
+
exclude:
|
17
|
+
- os: windows-latest
|
18
|
+
ruby: jruby
|
19
|
+
- os: windows-latest
|
20
|
+
ruby: truffleruby
|
21
|
+
runs-on: ${{ matrix.os }}
|
22
|
+
# continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v2
|
25
|
+
- uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
bundler-cache: true
|
29
|
+
# - run: bundle install
|
30
|
+
- if: matrix.ruby != 'jruby'
|
31
|
+
run: bundle exec rake test
|
32
|
+
- if: matrix.ruby == 'jruby'
|
33
|
+
run: bundle exec rake test TESTOPTS='--ignore-testcase=TestXmlMultibyteName'
|
data/.gitignore
CHANGED
data/README.ja.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
[[English](README.md)]
|
2
|
+
|
3
|
+
[](https://github.com/kenichiice/test-unit-runner-junitxml/actions?query=workflow%3ATest+branch%3Amaster)
|
4
|
+
|
5
|
+
# Test::Unit::Runner::JUnitXml
|
6
|
+
|
7
|
+
Test::Unit::Runner::JUnitXml は [test-unit](https://github.com/test-unit/test-unit) のテスト結果をJUnit XML形式で出力するライブラリです。
|
8
|
+
|
9
|
+
## インストール方法
|
10
|
+
|
11
|
+
$ gem install test-unit-runner-junitxml
|
12
|
+
|
13
|
+
## 使い方
|
14
|
+
|
15
|
+
`test/unit/runner/junitxml.rb` をロードすると、テストスクリプトの `--runner` オプションに `junitxml` を指定できるようになります。これを指定すると、テスト結果がJUnit XML形式で出力されるようになります。
|
16
|
+
|
17
|
+
また、 `--junitxml-output-file` オプションも追加され、このオプションで指定したファイルにテスト結果を出力することができるようになります。
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# test.rb
|
21
|
+
require "test/unit/runner/junitxml"
|
22
|
+
|
23
|
+
class MyTest < Test::Unit::TestCase
|
24
|
+
def test_1
|
25
|
+
print("hello")
|
26
|
+
assert_equal(1, 2)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
```
|
32
|
+
$ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
|
33
|
+
$ cat result.xml
|
34
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
35
|
+
<testsuites>
|
36
|
+
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.0037614">
|
37
|
+
<testcase classname="MyTest" name="test_1(MyTest)" file="test.rb" time="0.0036311" assertions="1">
|
38
|
+
<failure message="<1> expected but was
|
39
|
+
<2>.">Failure:
|
40
|
+
test_1(MyTest) [test.rb:7]:
|
41
|
+
<1> expected but was
|
42
|
+
<2>.</failure>
|
43
|
+
<system-out>hello</system-out>
|
44
|
+
</testcase>
|
45
|
+
</testsuite>
|
46
|
+
</testsuites>
|
47
|
+
```
|
48
|
+
|
49
|
+
## オプション
|
50
|
+
|
51
|
+
* --junitxml-output-file=FILE_NAME
|
52
|
+
* XMLを、標準出力ではなく指定したファイルへ出力します。
|
53
|
+
* --junitxml-disable-output-capture
|
54
|
+
* 標準出力と標準エラー出力のキャプチャを行わないようになります。
|
55
|
+
|
56
|
+
## ライセンス
|
57
|
+
|
58
|
+
[MIT License](https://opensource.org/licenses/MIT)
|
data/README.md
CHANGED
@@ -1,5 +1,58 @@
|
|
1
|
+
[[日本語](README.ja.md)]
|
2
|
+
|
3
|
+
[](https://github.com/kenichiice/test-unit-runner-junitxml/actions?query=workflow%3ATest+branch%3Amaster)
|
4
|
+
|
1
5
|
# Test::Unit::Runner::JUnitXml
|
2
6
|
|
3
|
-
[
|
7
|
+
Test::Unit::Runner::JUnitXml is a [test-unit](https://github.com/test-unit/test-unit) runner that reports test result in JUnit XML format.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
$ gem install test-unit-runner-junitxml
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
By loading `test/unit/runner/junitxml.rb`, you can select `junitxml` runner via the `--runner` command line option of test script. This runner reports test result in JUnit XML format.
|
16
|
+
|
17
|
+
In addition, `--junitxml-output-file` command line option is added, and it becomes possible to output the test result to the file specified by this option.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# test.rb
|
21
|
+
require "test/unit/runner/junitxml"
|
22
|
+
|
23
|
+
class MyTest < Test::Unit::TestCase
|
24
|
+
def test_1
|
25
|
+
print("hello")
|
26
|
+
assert_equal(1, 2)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
```
|
32
|
+
$ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
|
33
|
+
$ cat result.xml
|
34
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
35
|
+
<testsuites>
|
36
|
+
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.0037614">
|
37
|
+
<testcase classname="MyTest" name="test_1(MyTest)" file="test.rb" time="0.0036311" assertions="1">
|
38
|
+
<failure message="<1> expected but was
|
39
|
+
<2>.">Failure:
|
40
|
+
test_1(MyTest) [test.rb:7]:
|
41
|
+
<1> expected but was
|
42
|
+
<2>.</failure>
|
43
|
+
<system-out>hello</system-out>
|
44
|
+
</testcase>
|
45
|
+
</testsuite>
|
46
|
+
</testsuites>
|
47
|
+
```
|
48
|
+
|
49
|
+
## Options
|
50
|
+
|
51
|
+
* --junitxml-output-file=FILE_NAME
|
52
|
+
* Output XML to the specified file instead of the standard output.
|
53
|
+
* --junitxml-disable-output-capture
|
54
|
+
* Disable capture of standard output and standard error.
|
55
|
+
|
56
|
+
## License
|
4
57
|
|
5
|
-
|
58
|
+
[MIT License](https://opensource.org/licenses/MIT)
|
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
task :test do
|
7
|
-
ruby("test/run-test.rb")
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "lib"
|
6
|
+
t.test_files = FileList['test/**/test*.rb']
|
8
7
|
end
|
8
|
+
|
9
|
+
task :default => :test
|
@@ -12,6 +12,10 @@ module Test
|
|
12
12
|
"Outputs to FILE_NAME") do |name|
|
13
13
|
auto_runner.runner_options[:junitxml_output_file] = name
|
14
14
|
end
|
15
|
+
opts.on("--junitxml-disable-output-capture",
|
16
|
+
"Disable output capture") do |b|
|
17
|
+
auto_runner.runner_options[:junitxml_disable_output_capture] = b
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'erb'
|
2
|
+
require 'stringio'
|
2
3
|
require 'test/unit/ui/testrunner'
|
3
4
|
require 'test/unit/ui/testrunnermediator'
|
4
5
|
|
@@ -14,6 +15,7 @@ module Test
|
|
14
15
|
def initialize(suite, options={})
|
15
16
|
super
|
16
17
|
@junit_test_suites = []
|
18
|
+
@base_dir_re = /\A#{Regexp.quote(Dir.pwd)}\//
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
@@ -48,12 +50,28 @@ module Test
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def test_started(test)
|
51
|
-
|
52
|
-
|
53
|
+
test_case = JUnitTestCase.new(test.class.name, test.description, test_file(test))
|
54
|
+
@junit_test_suites.last << test_case
|
55
|
+
unless @options[:junitxml_disable_output_capture]
|
56
|
+
@stdout_org = $stdout
|
57
|
+
@stderr_org = $stderr
|
58
|
+
$stdout = test_case.stdout
|
59
|
+
$stderr = test_case.stderr
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_file(test)
|
64
|
+
file = (test[:source_location] ||
|
65
|
+
test.method(test.method_name).source_location).first
|
66
|
+
file.sub(@base_dir_re, "")
|
53
67
|
end
|
54
68
|
|
55
69
|
def test_finished(test)
|
56
70
|
@junit_test_suites.last.test_cases.last.time = test.elapsed_time
|
71
|
+
unless @options[:junitxml_disable_output_capture]
|
72
|
+
$stdout = @stdout_org
|
73
|
+
$stderr = @stderr_org
|
74
|
+
end
|
57
75
|
end
|
58
76
|
|
59
77
|
def result_pass_assertion(result)
|
@@ -114,17 +132,20 @@ module Test
|
|
114
132
|
end
|
115
133
|
|
116
134
|
class JUnitTestCase
|
117
|
-
attr_reader :class_name, :name
|
135
|
+
attr_reader :class_name, :name, :file
|
118
136
|
attr_reader :failure, :error, :omission, :pending
|
137
|
+
attr_reader :stdout, :stderr
|
119
138
|
attr_accessor :assertion_count, :time
|
120
139
|
|
121
|
-
def initialize(class_name, name)
|
140
|
+
def initialize(class_name, name, file)
|
122
141
|
@class_name = class_name
|
123
142
|
@name = name
|
143
|
+
@file = file
|
144
|
+
@failure = @error = @omission = @pending = nil
|
145
|
+
@stdout = StringIO.new
|
146
|
+
@stderr = StringIO.new
|
124
147
|
@assertion_count = 0
|
125
148
|
@time = 0
|
126
|
-
@omission = nil
|
127
|
-
@pending = nil
|
128
149
|
end
|
129
150
|
|
130
151
|
def <<(fault)
|
@@ -1,33 +1,26 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" ?>
|
2
2
|
<testsuites>
|
3
3
|
% @junit_test_suites.each do |test_suite|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
%
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
<skipped message="<%=h test_case.omission.message %>"/>
|
26
|
-
% elsif test_case.pending
|
27
|
-
<skipped message="<%=h test_case.pending.message %>"/>
|
28
|
-
% end
|
29
|
-
</testcase>
|
30
|
-
% end
|
31
|
-
</testsuite>
|
4
|
+
<testsuite name="<%=h test_suite.name %>" tests="<%=h test_suite.test_cases.size %>" errors="<%=h test_suite.errors.size %>" failures="<%=h test_suite.failures.size %>" skipped="<%=h test_suite.test_cases.count(&:skipped?) %>" time="<%=h test_suite.time %>">
|
5
|
+
% test_suite.test_cases.each do |test_case|
|
6
|
+
<testcase classname="<%=h test_case.class_name %>" name="<%=h test_case.name %>" file="<%=h test_case.file%>" time="<%=h test_case.time %>" assertions="<%=h test_case.assertion_count %>">
|
7
|
+
% if test_case.error
|
8
|
+
<error message="<%=h test_case.error.message %>" type="<%=h test_case.error.exception.class.name %>"><%=h test_case.error.long_display %></error>
|
9
|
+
% elsif test_case.failure
|
10
|
+
<failure message="<%=h test_case.failure.message %>"><%=h test_case.failure.long_display %></failure>
|
11
|
+
% elsif test_case.omission
|
12
|
+
<skipped message="<%=h test_case.omission.message %>"/>
|
13
|
+
% elsif test_case.pending
|
14
|
+
<skipped message="<%=h test_case.pending.message %>"/>
|
15
|
+
% end
|
16
|
+
% if test_case.stdout.size > 0
|
17
|
+
<system-out><%=h test_case.stdout.string %></system-out>
|
18
|
+
% end
|
19
|
+
% if test_case.stderr.size > 0
|
20
|
+
<system-err><%=h test_case.stderr.string %></system-err>
|
21
|
+
% end
|
22
|
+
</testcase>
|
23
|
+
% end
|
24
|
+
</testsuite>
|
32
25
|
% end
|
33
26
|
</testsuites>
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "test/unit/runner/junitxml/version"
|
@@ -11,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
11
10
|
|
12
11
|
spec.summary = %q{A test-unit runner that reports test result in JUnit XML format.}
|
13
12
|
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
-
|
13
|
+
spec.homepage = "https://github.com/kenichiice/test-unit-runner-junitxml"
|
15
14
|
spec.license = "MIT"
|
16
15
|
|
17
16
|
# Specify which files should be added to the gem when it is released.
|
@@ -23,8 +22,9 @@ Gem::Specification.new do |spec|
|
|
23
22
|
#spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
23
|
spec.require_paths = ["lib"]
|
25
24
|
|
26
|
-
spec.add_development_dependency "bundler"
|
27
|
-
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rexml"
|
28
28
|
|
29
|
-
spec.add_runtime_dependency "test-unit"
|
29
|
+
spec.add_runtime_dependency "test-unit"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,68 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-unit-runner-junitxml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OGAWA KenIchi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rexml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: test-unit
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description:
|
68
|
+
version: '0'
|
69
|
+
description:
|
56
70
|
email:
|
57
71
|
- kenichi@ice.email.ne.jp
|
58
72
|
executables: []
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- ".github/workflows/test.yml"
|
62
77
|
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
78
|
- Gemfile
|
65
79
|
- LICENSE.txt
|
80
|
+
- README.ja.md
|
66
81
|
- README.md
|
67
82
|
- Rakefile
|
68
83
|
- lib/test/unit/runner/junitxml.rb
|
@@ -70,11 +85,11 @@ files:
|
|
70
85
|
- lib/test/unit/ui/junitxml/testrunner.rb
|
71
86
|
- lib/test/unit/ui/junitxml/xml.erb
|
72
87
|
- test-unit-runner-junitxml.gemspec
|
73
|
-
homepage:
|
88
|
+
homepage: https://github.com/kenichiice/test-unit-runner-junitxml
|
74
89
|
licenses:
|
75
90
|
- MIT
|
76
91
|
metadata: {}
|
77
|
-
post_install_message:
|
92
|
+
post_install_message:
|
78
93
|
rdoc_options: []
|
79
94
|
require_paths:
|
80
95
|
- lib
|
@@ -89,9 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
104
|
- !ruby/object:Gem::Version
|
90
105
|
version: '0'
|
91
106
|
requirements: []
|
92
|
-
|
93
|
-
|
94
|
-
signing_key:
|
107
|
+
rubygems_version: 3.3.3
|
108
|
+
signing_key:
|
95
109
|
specification_version: 4
|
96
110
|
summary: A test-unit runner that reports test result in JUnit XML format.
|
97
111
|
test_files: []
|