Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.98 KB

README.ja.md

File metadata and controls

58 lines (43 loc) · 1.98 KB

[English]

Test

Test::Unit::Runner::JUnitXml

Test::Unit::Runner::JUnitXml は test-unit のテスト結果をJUnit XML形式で出力するライブラリです。

インストール方法

$ gem install test-unit-runner-junitxml

使い方

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

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

# test.rb
require "test/unit/runner/junitxml"

class MyTest < Test::Unit::TestCase
  def test_1
    print("hello")
    assert_equal(1, 2)
  end
end
$ 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.0037614">
		<testcase classname="MyTest" name="test_1(MyTest)" file="test.rb" time="0.0036311" assertions="1">
			<failure message="&lt;1&gt; expected but was
&lt;2&gt;.">Failure:
test_1(MyTest) [test.rb:7]:
&lt;1&gt; expected but was
&lt;2&gt;.</failure>
			<system-out>hello</system-out>
		</testcase>
	</testsuite>
</testsuites>

オプション

  • --junitxml-output-file=FILE_NAME
    • XMLを、標準出力ではなく指定したファイルへ出力します。
  • --junitxml-disable-output-capture
    • 標準出力と標準エラー出力のキャプチャを行わないようになります。

ライセンス

MIT License