2006年05月27日

Test::Unitのサンプル

Test::Unitの説明します。
使用するにはTest::Unit::Proceduralをuseします。
use Test::Unit::Procedural;
次のファイルをsapmle.plという名前で保存します。
use Test::Unit::Procedural;

#テスト対象
sub hello {
	return "hello"
}


#テスト(成功)
sub test_success {
	my $str = hello();
	assert($str eq "hello", "test_success失敗です。");
}

#テスト(失敗)
sub test_failuer {
	my $str = hello();
	assert($str eq "test", "test_failuer失敗です。");
}

sub set_up {
	print "set_up called\n";
}

sub tear_down {
	print "tear_down called\n";
}



#テストの実行
create_suite();
run_suite();
実行結果は、次の様になります。
> perl sample.pl
.set_up called
tear_down called
.set_up called
tear_down called
F
Time:  0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)

!!!FAILURES!!!
Test Results:
Run: 2, Failures: 1, Errors: 0

There was 1 failure:
1) /usr/local/lib/perl5/site_perl/5.8.6/Class/Inner.pm:116 - test_failuer(Class::Inner::__A1)
test_failuer失敗です。

Test was not successful.

2006年05月その他のエントリー

  1. 2006年05月27日

    1. Test::Unitのインストール(Test::Unit)(5)

    2. Test::Unitのインストール(Test::Unit)(4)

    3. Test::Unitのインストール(Test::Unit)(3)

    4. Test::Unitのインストール(Test::Unit)(2)

    5. Test::Unitのインストール(Test::Unit)(1)

    6. Test::Unitのインストール(Error)(5)

    7. Test::Unitのインストール(Error)(4)

    8. Test::Unitのインストール(Error)(3)

    9. Test::Unitのインストール(Error)(2)

    10. Test::Unitのインストール(Error)(1)

    11. Test::Unitのインストール(Devel::Symdump)(5)

    12. Test::Unitのインストール(Devel::Symdump)(4)

    13. Test::Unitのインストール(Devel::Symdump)(3)

    14. Test::Unitのインストール(Devel::Symdump)(2)

    15. Test::Unitのインストール(Devel::Symdump)(1)

    16. Test::Unitのインストール(Class::Inner)(5)

    17. Test::Unitのインストール(Class::Inner)(4)

    18. Test::Unitのインストール(Class::Inner)(3)

    19. Test::Unitのインストール(Class::Inner)(2)

    20. Test::Unitのインストール(Class::Inner)(1)

    21. Test::Unitのインストール(1)

    22. Test::Unitのダウンロード(Error)

    23. Test::Unitのダウンロード(Devel::Symdump)

    24. Test::Unitのダウンロード(Class::Inner)

    25. Test::Unitのダウンロード(Test::Unit)

    26. Test::Unitのダウンロード(1)

    27. DBI/DBD-pgサンプル(selectall_arrayref)

    28. DBI/DBD-pgサンプル(fetchrow_array)

    29. DBI/DBD-pgサンプル(selectrow_array)

    30. DBI/DBD-pgサンプル(prepare)

    31. DBI/DBD-pgサンプル(do)

    32. DBI/DBD-pgサンプル(disconnect)

    33. DBI/DBD-pgサンプル(connect)

    34. DBI/DBD-pgサンプル(テーブル作成)

    35. DBD-Pgのインストール(5)

    36. DBD-Pgのインストール(4)

    37. DBD-Pgのインストール(3)

    38. DBD-Pgのインストール(2)

    39. DBD-Pgのインストール(1)

    40. DBD-Pgのダウンロード(1)

    41. DBIのインストール(5)

    42. DBIのインストール(4)

    43. DBIのインストール(3)

    44. DBIのインストール(2)

    45. DBIのインストール(1)

    46. DBIのダウンロード(1)