Skip to content

Commit

Permalink
Merge pull request #8 from kenichiice/xml-format
Browse files Browse the repository at this point in the history
XMLのサイズを減らす
  • Loading branch information
kenichiice authored Jan 5, 2022
2 parents 59c4396 + 1e53ab3 commit 231352b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.bundle/
/.ruby-version
/.yardoc
/_yardoc/
/Gemfile.lock
Expand Down
22 changes: 7 additions & 15 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Test::Unit::Runner::JUnitXml は [test-unit](https://github.com/test-unit/test-u

## 使い方

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

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

Expand All @@ -32,25 +32,17 @@ $ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
$ cat result.xml
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite name="MyTest"
tests="1"
errors="0"
failures="1"
skipped="0"
time="0.0048183">
<testcase classname="MyTest"
name="test_1(MyTest)"
time="0.0047834"
assertions="1">
<failure message="&lt;1&gt; expected but was
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.0027089">
<testcase classname="MyTest" name="test_1(MyTest)" time="0.0026767" assertions="1">
<failure message="&lt;1&gt; expected but was
&lt;2&gt;.">
Failure:
test_1(MyTest) [test.rb:6]:
&lt;1&gt; expected but was
&lt;2&gt;.
</failure>
</testcase>
</testsuite>
</failure>
</testcase>
</testsuite>
</testsuites>
```

Expand Down
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,17 @@ $ ruby test.rb --runner=junitxml --junitxml-output-file=result.xml
$ cat result.xml
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite name="MyTest"
tests="1"
errors="0"
failures="1"
skipped="0"
time="0.0048183">
<testcase classname="MyTest"
name="test_1(MyTest)"
time="0.0047834"
assertions="1">
<failure message="&lt;1&gt; expected but was
<testsuite name="MyTest" tests="1" errors="0" failures="1" skipped="0" time="0.0027089">
<testcase classname="MyTest" name="test_1(MyTest)" time="0.0026767" assertions="1">
<failure message="&lt;1&gt; expected but was
&lt;2&gt;.">
Failure:
test_1(MyTest) [test.rb:6]:
&lt;1&gt; expected but was
&lt;2&gt;.
</failure>
</testcase>
</testsuite>
</failure>
</testcase>
</testsuite>
</testsuites>
```

Expand Down
43 changes: 17 additions & 26 deletions lib/test/unit/ui/junitxml/xml.erb
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
% @junit_test_suites.each do |test_suite|
<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 %>">
% test_suite.test_cases.each do |test_case|
<testcase classname="<%=h test_case.class_name %>"
name="<%=h test_case.name %>"
time="<%=h test_case.time %>"
assertions="<%=h test_case.assertion_count %>">
% if test_case.error
<error message="<%=h test_case.error.message %>"
type="<%=h test_case.error.exception.class.name %>">
<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 %>">
% test_suite.test_cases.each do |test_case|
<testcase classname="<%=h test_case.class_name %>" name="<%=h test_case.name %>" time="<%=h test_case.time %>" assertions="<%=h test_case.assertion_count %>">
% if test_case.error
<error message="<%=h test_case.error.message %>" type="<%=h test_case.error.exception.class.name %>">
<%=h test_case.error.long_display %>
</error>
% elsif test_case.failure
<failure message="<%=h test_case.failure.message %>">
</error>
% elsif test_case.failure
<failure message="<%=h test_case.failure.message %>">
<%=h test_case.failure.long_display %>
</failure>
% elsif test_case.omission
<skipped message="<%=h test_case.omission.message %>"/>
% elsif test_case.pending
<skipped message="<%=h test_case.pending.message %>"/>
% end
</testcase>
% end
</testsuite>
</failure>
% elsif test_case.omission
<skipped message="<%=h test_case.omission.message %>"/>
% elsif test_case.pending
<skipped message="<%=h test_case.pending.message %>"/>
% end
</testcase>
% end
</testsuite>
% end
</testsuites>

0 comments on commit 231352b

Please sign in to comment.