Skip to content

Commit 231352b

Browse files
authored
Merge pull request #8 from kenichiice/xml-format
XMLのサイズを減らす
2 parents 59c4396 + 1e53ab3 commit 231352b

File tree

4 files changed

+31
-55
lines changed

4 files changed

+31
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.bundle/
2+
/.ruby-version
23
/.yardoc
34
/_yardoc/
45
/Gemfile.lock

README.ja.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Test::Unit::Runner::JUnitXml は [test-unit](https://github.com/test-unit/test-u
1212

1313
## 使い方
1414

15-
`test/unit/runner/junitxml.rb` をロードすると、テストスクリプトの `--runner` オプションに `junitxml` を指定できるようになります。これを指定すると、テスト結果がJUnit XML形式で出力されれうようになります
15+
`test/unit/runner/junitxml.rb` をロードすると、テストスクリプトの `--runner` オプションに `junitxml` を指定できるようになります。これを指定すると、テスト結果がJUnit XML形式で出力されるようになります
1616

1717
また、 `--junitxml-output-file` オプションも追加され、このオプションで指定したファイルにテスト結果を出力することができるようになります。
1818

@@ -32,25 +32,17 @@ $ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
3232
$ cat result.xml
3333
<?xml version="1.0" encoding="UTF-8" ?>
3434
<testsuites>
35-
<testsuite name="MyTest"
36-
tests="1"
37-
errors="0"
38-
failures="1"
39-
skipped="0"
40-
time="0.0048183">
41-
<testcase classname="MyTest"
42-
name="test_1(MyTest)"
43-
time="0.0047834"
44-
assertions="1">
45-
<failure message="&lt;1&gt; expected but was
35+
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.0027089">
36+
<testcase classname="MyTest" name="test_1(MyTest)" time="0.0026767" assertions="1">
37+
<failure message="&lt;1&gt; expected but was
4638
&lt;2&gt;.">
4739
Failure:
4840
test_1(MyTest) [test.rb:6]:
4941
&lt;1&gt; expected but was
5042
&lt;2&gt;.
51-
</failure>
52-
</testcase>
53-
</testsuite>
43+
</failure>
44+
</testcase>
45+
</testsuite>
5446
</testsuites>
5547
```
5648

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,17 @@ $ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
3232
$ cat result.xml
3333
<?xml version="1.0" encoding="UTF-8" ?>
3434
<testsuites>
35-
<testsuite name="MyTest"
36-
tests="1"
37-
errors="0"
38-
failures="1"
39-
skipped="0"
40-
time="0.0048183">
41-
<testcase classname="MyTest"
42-
name="test_1(MyTest)"
43-
time="0.0047834"
44-
assertions="1">
45-
<failure message="&lt;1&gt; expected but was
35+
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.0027089">
36+
<testcase classname="MyTest" name="test_1(MyTest)" time="0.0026767" assertions="1">
37+
<failure message="&lt;1&gt; expected but was
4638
&lt;2&gt;.">
4739
Failure:
4840
test_1(MyTest) [test.rb:6]:
4941
&lt;1&gt; expected but was
5042
&lt;2&gt;.
51-
</failure>
52-
</testcase>
53-
</testsuite>
43+
</failure>
44+
</testcase>
45+
</testsuite>
5446
</testsuites>
5547
```
5648

lib/test/unit/ui/junitxml/xml.erb

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<testsuites>
33
% @junit_test_suites.each do |test_suite|
4-
<testsuite name="<%=h test_suite.name %>"
5-
tests="<%=h test_suite.test_cases.size %>"
6-
errors="<%=h test_suite.errors.size %>"
7-
failures="<%=h test_suite.failures.size %>"
8-
skipped="<%=h test_suite.test_cases.count(&:skipped?) %>"
9-
time="<%=h test_suite.time %>">
10-
% test_suite.test_cases.each do |test_case|
11-
<testcase classname="<%=h test_case.class_name %>"
12-
name="<%=h test_case.name %>"
13-
time="<%=h test_case.time %>"
14-
assertions="<%=h test_case.assertion_count %>">
15-
% if test_case.error
16-
<error message="<%=h test_case.error.message %>"
17-
type="<%=h test_case.error.exception.class.name %>">
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 %>" 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 %>">
189
<%=h test_case.error.long_display %>
19-
</error>
20-
% elsif test_case.failure
21-
<failure message="<%=h test_case.failure.message %>">
10+
</error>
11+
% elsif test_case.failure
12+
<failure message="<%=h test_case.failure.message %>">
2213
<%=h test_case.failure.long_display %>
23-
</failure>
24-
% elsif test_case.omission
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>
14+
</failure>
15+
% elsif test_case.omission
16+
<skipped message="<%=h test_case.omission.message %>"/>
17+
% elsif test_case.pending
18+
<skipped message="<%=h test_case.pending.message %>"/>
19+
% end
20+
</testcase>
21+
% end
22+
</testsuite>
3223
% end
3324
</testsuites>

0 commit comments

Comments
 (0)