一歩進んだ使い方
すべてのテストを実行する
すべてのテストを簡単に実行するために、 run.rb スクリプトを test ディレクトリにおきます。スクリプトは以下のようにします。
base_dir = File.(File.join(File.dirname(__FILE__), ".."))
lib_dir  = File.join(base_dir, "lib")
test_dir = File.join(base_dir, "test")
$LOAD_PATH.unshift(lib_dir)
require 'test/unit'
exit Test::Unit::AutoRunner.run(true, test_dir)
これで以下のコマンドで簡単にテストを実行できます。
$ ruby test/run.rb
コマンドラインでテストランナーを変更する
テスト結果の出力フォーマットはコマンドラインで --runner オプションを指定すると変更できます。単純にこのオプションを最後に追加してください。
ruby test/run.rb --runner emacs
プロジェクトごとにtest-unitを設定する
Test::Unitは ~/.test-unit.yml または現在のワーキングディレクトリにある test-unit.yml をTest::Unitの設定ファイルとして読み込みます。このファイルには以下のような設定をすることができます。
- color scheme definitions
 - test runner to be used
 - test runner options
 - test collector to be used
 
カラースキーム定義以外はコマンドラインオプションで指定することができます。
以下はカラースキームの定義例です。
color_schemes:
  inverted:
    success:
      name: red
      bold: true
    failure:
      name: green
      bold: true
  other_scheme:
    ...
Here are the syntax of color scheme definitions:
color_schemes:
  SCHEME_NAME:
    EVENT_NAME:
      name: COLOR_NAME
      intensity: BOOLEAN
      bold: BOOLEAN
      italic: BOOLEAN
      underline: BOOLEAN
    ...
  ...
| Definition | Description | 
|---|---|
| SCHEME_NAME | the name of the color scheme | 
| EVENT_NAME | success, failure, pending, omission, notification, error | 
| COLOR_NAME | black, red, green, yellow, blue, magenta, cyan, white | 
| BOOLEAN | true or false | 
上で定義した’inverted’カラースキムを使う設定は以下の通りです。
runner: console
console_options:
  color_scheme: inverted
color_schemes:
  inverted:
    success:
      name: red
      bold: true
    failure:
      name: green
      bold: true