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.

Perlその他のエントリー

  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)

  2. 2006年02月23日

    1. サーバーソケット

    2. クライアントソケット

  3. 2006年02月08日

    1. stat

    2. exec

    3. system

    4. ファイルテスト演算子(s)

    5. ファイルテスト演算子(S)

    6. ファイルテスト演算子(B)

    7. ファイルテスト演算子(x)

    8. ファイルテスト演算子(w)

    9. ファイルテスト演算子(r)

    10. ファイルテスト演算子(p)

    11. ファイルテスト演算子(o)

    12. ファイルテスト演算子(l)

    13. ファイルテスト演算子(f)

    14. ファイルテスト演算子(d)

    15. ファイルテスト演算子(e)

    16. ファイルテスト演算子

    17. ディレクトリ操作

    18. rmdir

    19. chdir

    20. mkdir

    21. chmod

    22. unlink

    23. rename

    24. 引数

    25. 特殊な読み込み

    26. STDERR

    27. STDOUT

    28. STDIN

    29. ファイル(追記)

    30. ファイル(書き出し)

    31. ファイル(3)

    32. ファイル(2)

    33. ファイル(1)

    34. モジュール(3)

    35. モジュール(2)

    36. モジュール(1)

    37. ライブラリ

    38. リファレンス(ハッシュ)(2)

    39. リファレンス(ハッシュ)

    40. リファレンス(配列)(2)

    41. リファレンス(配列)(1)

    42. リファレンス(スカラー変数)

    43. ローカル変数(local)

    44. ローカル変数(my)

    45. グローバル変数

    46. サブルーチン(戻り値)(2)

    47. サブルーチン(戻り値)(1)

    48. サブルーチン(引数)

    49. サブルーチン

  4. 2006年02月07日

    1. reverse関数

    2. sort関数(3)

    3. sort関数(2)

    4. sort関数(1)