Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > test/unit/autorunnerライブラリ > Test::Unit::AutoRunnerクラス

class Test::Unit::AutoRunner

クラスの継承リスト: Test::Unit::AutoRunner < Object < Kernel

要約

テストの実行を操作したいときにこの AutoRunner クラスを使います。 大量のテストの中から特定のテストスクリプトのみを実行したい場合、 特定のテストクラスのみを実行したい場合などに使います。 AutoRunner は Collector::Dir オブジェクトなどの Collector に テストを集めさせて、UI::Console::TestRunner オブジェクトなどの Runner にテストを実行させているクラスです。

ディレクトリ ./somedir 以下にある全てのテストを実行したい場合は次のようなファイル(runner.rb)を用意して実行します。テストは test_*.rb というファイル名である必要があります。

第一引数に true を与えると、./somedir 以下にある全てのテストを実行します。

require 'test/unit'
Test::Unit::AutoRunner.run(true, './somedir')

単に実行します。

$ ruby runner.rb

ディレクトリ ./somedir 以下にあるテストをファイル somefile を除いて実行したい場合は次のように runner.rb にオプションを与えます。

$ ruby runner.rb --exclude=somefile

同じことは、runner.rb に直接オプションを書いても実現できます。

require 'test/unit'
Test::Unit::AutoRunner.run(true, './somedir', ['--exclude=somefile'])

上のやり方では拡張子が .rb のファイルしか集めません。拡張子が .rbx のファイルも テストとして集めたい場合は次のようにします。

require 'test/unit'
Test::Unit::AutoRunner.run(true, './somedir', ['--pattern=/test_.*\.rbx\Z/'])

特異メソッド

定義 説明
run(force_standalone = false, dir = '.', argv = ARGV) -> bool

テストを実行します。全てのテストが成功した場合、true を返します。そうでない場合は、 false を返します。

継承したメソッド

== === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style untaint .new