0
複数のテストを同じファイルにまとめたいと思っています。後で単一のテストとして実行します。スタンドアロンとしてテストを実行するには?
例: はtests/TC_release1.rb
- それのように10回のテストとテストファイル
ruby tests/TC_release1.rb --name test_TC_01
- 単一のテストを実行するには
すべてのテストは、私の場合(初期化されます10回)。
私がすることを回避し、スタンドアローンモードで実行するにはどうすればよい:これはhttp://test-unit.github.io/test-unit/en/Test/Unit/TestCase.html
質問にドキュメントに記載された「コール・オーダー」のでしょうか? phoetによって示唆されるよう$ cat tests/TC_release1.rb
require 'rubygems'
require 'date'
require 'test/unit'
class TC_release1 < Test::Unit::TestCase
def initialize(options)
super
puts DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")+" Hello from the init method."
end
def test_TC_01()
puts DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")+" Start test 01"
assert_match(/2017/, `date /T`)
puts DateTime.now.strftime("%Y-%m-%dT%H:%M:%S")+" End test 01"
end
def test_TC_02()
assert_match(/2017/, `date /T`)
end
def test_TC_03()
assert_match(/2017/, `date /T`)
end
def test_TC_04()
assert_match(/2017/, `date /T`)
end
def test_TC_05()
assert_match(/2017/, `date /T`)
end
def test_TC_06()
assert_match(/2017/, `date /T`)
end
def test_TC_07()
assert_match(/2017/, `date /T`)
end
def test_TC_08()
assert_match(/2017/, `date /T`)
end
def test_TC_09()
assert_match(/2017/, `date /T`)
end
def test_TC_10()
assert_match(/2017/, `date /T`)
end
end
テストファイル
$ ruby tests/TC_release1.rb --name test_TC_01
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
2017-09-13T00:31:16 Hello from the init method.
Loaded suite tests/TC_release1
Started
2017-09-13T00:31:16 Start test 01
2017-09-13T00:31:16 End test 01
.
Finished in 0.048923 seconds.
--------------------------------------------------------------------------------------------------------------------------------------------------------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
--------------------------------------------------------------------------------------------------------------------------------------------------------
20.44 tests/s, 20.44 assertions/s
「すべてのテストを初期化する」とはどういう意味ですか?実際にテストのうちの1つだけを実行すべき集中テストをしている場合。 – tadman
イニシャライザをオーバーライドしないでください。セットアップが必要な場合は、before/setupフックを使用してください – phoet