test-unit-runner-junitxml 0.1.2 → 0.2.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 +4 -4
- data/README.ja.md +14 -7
- data/README.md +14 -7
- 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 +17 -4
- data/lib/test/unit/ui/junitxml/xml.erb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc822c3eb15c8429e1bf4a416b8d851445949fdcd70e911e978c54e93ef185f
|
4
|
+
data.tar.gz: 9019e7126e6c0d038ee23596de5c94e9b0151cd49cad5c295b94535991fd5a8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cccd48257f5637df20b4e1df12a9018dce9a60b93c00743291cd841c212dcc97929de63863a65013b4813068e06f6d4fe0bf34c4b220cbc349ce100540b12051
|
7
|
+
data.tar.gz: b2d1012a3d79972dea86c3e3c05815e0f87293386b39d188b9672c19a692385964816a60924b5207296ebe0a8860f47a0faaa358e88d25c9513d520025aa96a5
|
data/README.ja.md
CHANGED
@@ -22,6 +22,7 @@ require "test/unit/runner/junitxml"
|
|
22
22
|
|
23
23
|
class MyTest < Test::Unit::TestCase
|
24
24
|
def test_1
|
25
|
+
print("hello")
|
25
26
|
assert_equal(1, 2)
|
26
27
|
end
|
27
28
|
end
|
@@ -32,20 +33,26 @@ $ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
|
|
32
33
|
$ cat result.xml
|
33
34
|
<?xml version="1.0" encoding="UTF-8" ?>
|
34
35
|
<testsuites>
|
35
|
-
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.
|
36
|
-
<testcase classname="MyTest" name="test_1(MyTest)" time="0.
|
36
|
+
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.005365">
|
37
|
+
<testcase classname="MyTest" name="test_1(MyTest)" time="0.0053308" assertions="1">
|
37
38
|
<failure message="<1> expected but was
|
38
|
-
<2>.">
|
39
|
-
|
40
|
-
test_1(MyTest) [test.rb:6]:
|
39
|
+
<2>.">Failure:
|
40
|
+
test_1(MyTest) [test.rb:7]:
|
41
41
|
<1> expected but was
|
42
|
-
<2>
|
43
|
-
</
|
42
|
+
<2>.</failure>
|
43
|
+
<system-out>hello</system-out>
|
44
44
|
</testcase>
|
45
45
|
</testsuite>
|
46
46
|
</testsuites>
|
47
47
|
```
|
48
48
|
|
49
|
+
## オプション
|
50
|
+
|
51
|
+
* --junitxml-output-file=FILE_NAME
|
52
|
+
* XMLを、標準出力ではなく指定したファイルへ出力します。
|
53
|
+
* --junitxml-disable-output-capture
|
54
|
+
* 標準出力と標準エラー出力のキャプチャを行わないようになります。
|
55
|
+
|
49
56
|
## ライセンス
|
50
57
|
|
51
58
|
[MIT License](https://opensource.org/licenses/MIT)
|
data/README.md
CHANGED
@@ -22,6 +22,7 @@ require "test/unit/runner/junitxml"
|
|
22
22
|
|
23
23
|
class MyTest < Test::Unit::TestCase
|
24
24
|
def test_1
|
25
|
+
print("hello")
|
25
26
|
assert_equal(1, 2)
|
26
27
|
end
|
27
28
|
end
|
@@ -32,20 +33,26 @@ $ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
|
|
32
33
|
$ cat result.xml
|
33
34
|
<?xml version="1.0" encoding="UTF-8" ?>
|
34
35
|
<testsuites>
|
35
|
-
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.
|
36
|
-
<testcase classname="MyTest" name="test_1(MyTest)" time="0.
|
36
|
+
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.005365">
|
37
|
+
<testcase classname="MyTest" name="test_1(MyTest)" time="0.0053308" assertions="1">
|
37
38
|
<failure message="<1> expected but was
|
38
|
-
<2>.">
|
39
|
-
|
40
|
-
test_1(MyTest) [test.rb:6]:
|
39
|
+
<2>.">Failure:
|
40
|
+
test_1(MyTest) [test.rb:7]:
|
41
41
|
<1> expected but was
|
42
|
-
<2>
|
43
|
-
</
|
42
|
+
<2>.</failure>
|
43
|
+
<system-out>hello</system-out>
|
44
44
|
</testcase>
|
45
45
|
</testsuite>
|
46
46
|
</testsuites>
|
47
47
|
```
|
48
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
|
+
|
49
56
|
## License
|
50
57
|
|
51
58
|
[MIT License](https://opensource.org/licenses/MIT)
|
@@ -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
|
|
@@ -48,12 +49,22 @@ module Test
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def test_started(test)
|
51
|
-
|
52
|
-
|
52
|
+
test_case = JUnitTestCase.new(test.class.name, test.description)
|
53
|
+
@junit_test_suites.last << test_case
|
54
|
+
unless @options[:junitxml_disable_output_capture]
|
55
|
+
@stdout_org = $stdout
|
56
|
+
@stderr_org = $stderr
|
57
|
+
$stdout = test_case.stdout
|
58
|
+
$stderr = test_case.stderr
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
55
62
|
def test_finished(test)
|
56
63
|
@junit_test_suites.last.test_cases.last.time = test.elapsed_time
|
64
|
+
unless @options[:junitxml_disable_output_capture]
|
65
|
+
$stdout = @stdout_org
|
66
|
+
$stderr = @stderr_org
|
67
|
+
end
|
57
68
|
end
|
58
69
|
|
59
70
|
def result_pass_assertion(result)
|
@@ -116,15 +127,17 @@ module Test
|
|
116
127
|
class JUnitTestCase
|
117
128
|
attr_reader :class_name, :name
|
118
129
|
attr_reader :failure, :error, :omission, :pending
|
130
|
+
attr_reader :stdout, :stderr
|
119
131
|
attr_accessor :assertion_count, :time
|
120
132
|
|
121
133
|
def initialize(class_name, name)
|
122
134
|
@class_name = class_name
|
123
135
|
@name = name
|
136
|
+
@failure = @error = @omission = @pending = nil
|
137
|
+
@stdout = StringIO.new
|
138
|
+
@stderr = StringIO.new
|
124
139
|
@assertion_count = 0
|
125
140
|
@time = 0
|
126
|
-
@omission = nil
|
127
|
-
@pending = nil
|
128
141
|
end
|
129
142
|
|
130
143
|
def <<(fault)
|
@@ -5,17 +5,19 @@
|
|
5
5
|
% test_suite.test_cases.each do |test_case|
|
6
6
|
<testcase classname="<%=h test_case.class_name %>" name="<%=h test_case.name %>" time="<%=h test_case.time %>" assertions="<%=h test_case.assertion_count %>">
|
7
7
|
% if test_case.error
|
8
|
-
<error message="<%=h test_case.error.message %>" type="<%=h test_case.error.exception.class.name %>">
|
9
|
-
<%=h test_case.error.long_display %>
|
10
|
-
</error>
|
8
|
+
<error message="<%=h test_case.error.message %>" type="<%=h test_case.error.exception.class.name %>"><%=h test_case.error.long_display %></error>
|
11
9
|
% elsif test_case.failure
|
12
|
-
<failure message="<%=h test_case.failure.message %>">
|
13
|
-
<%=h test_case.failure.long_display %>
|
14
|
-
</failure>
|
10
|
+
<failure message="<%=h test_case.failure.message %>"><%=h test_case.failure.long_display %></failure>
|
15
11
|
% elsif test_case.omission
|
16
12
|
<skipped message="<%=h test_case.omission.message %>"/>
|
17
13
|
% elsif test_case.pending
|
18
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>
|
19
21
|
% end
|
20
22
|
</testcase>
|
21
23
|
% end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OGAWA KenIchi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|