Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLのサイズを減らす #8

Merged
merged 4 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>