run(force_standalone = false, dir = '.', argv = ARGV) -> bool[permalink][rdoc]-
テストを実行します。全てのテストが成功した場合、true を返します。そうでない場合は、 false を返します。
- [PARAM] force_standalone:
- true を与えると、dir 以下にある全てのテストを実行します。false を与えた場合は既に読み込まれたファイルの中からテストを探して実行します。テストが読み込まれておらず、スクリプトを -e から実行している場合は、dir 以下にある全てのテストを実行します。デフォルトは false です。
- [PARAM] dir:
- force_standalone に true を与えた時に再帰的に探査するディレクトリ名を与えます。デフォルトではカレントディレクトリを再帰的に探査します。
- [PARAM] argv:
- オプションを配列として与えます。解釈するオプションは先に出てきたものと同じです。
-r, --runner=RUNNER Use the given RUNNER. (c[onsole], f[ox], g[tk], g[tk]2, t[k]) -b, --basedir=DIR Base directory of test suites. -w, --workdir=DIR Working directory to run tests. -n, --name=NAME Runs tests matching NAME. (patterns may be used). -t, --testcase=TESTCASE Runs tests in TestCases matching TESTCASE. (patterns may be used). -v, --verbose=[LEVEL] Set the output level (default is verbose). (s[ilent], p[rogress], n[ormal], v[erbose]) -- Stop processing options so that the remaining options will be passed to the test. -h, --help Display this help.force_standalone に false を与えた時には次のオプションが追加されます。
-a, --add=TORUN Add TORUN to the list of things to run; can be a file or a directory. -p, --pattern=PATTERN Match files to collect against PATTERN. -x, --exclude=PATTERN Ignore files to collect against PATTERN.例
require 'test/unit' Test::Unit::AutoRunner.run(true, './', ['--runner=tk', '-v', '--exclude=/test_hoge.*\.rb\Z/i'])argv にデフォルトのまま ARGV を渡しておけばコマンドラインからオプションを指定できます。
require 'test/unit' Test::Unit::AutoRunner.run(true, './')
と、runner.rb に書いておいて、コマンドラインから以下のように実行。
$ ruby runner.rb --runner=tk -v --exclude=/test_hoge.\*\\.rb\\Z/i