1. CmdUnitとは
CmdUnit はコマンドのテストを行うための Ruby API です。 助田さんの書かれたRubyのテストフレームワーク - RubyUnitと組み合わせて使用し、 コマンドのテストを自動化することができます。
2. ダウンロードとインストール
http://xpenguin.biz/download/cmdunit/ から cmdunit-20YYMMDD-*.tar.gz をダウンロードし、適当なディレクトリに展開して、 ``ruby install.rb'' してください。
3. 使用例
3.1. ソース
require 'cmdunit/cmdunit'
class TestSample < CmdUnit::TestCase
def setup
ENV['LANG'] = 'C'
end
def test_echo
result = Command::new( "echo a" ).exec
assert_status( 0, result )
assert_output( "a\n", "", result )
end
def test_ls
command = Command::new( "ls %s" )
command.exec( 'dummy' )
assert_status( 1, command )
assert_output( "", "ls: dummy: No such file or directory\n", command )
command.exec( '-d /' )
assert_status( 0, command )
assert_output( "/\n", "", command )
end
end
3.2. 実行結果
TestSample#test_echo . TestSample#test_ls . Time: 0.074055 OK (2/2 tests 6 asserts)
4. 配布条件
本プログラムはフリーソフトウェアです。 GPL(the GNU GeneralPublic License)、 または、Ruby本体と同じ条件で本プログラムを再配布できます。 GPLについてはCOPYINGファイルを参照して下さい。
5. バグレポート
6. 変更履歴
20010606-alpha -> now
- Command#stdin : add input for a command
- assert_output : new
- assert_status : new
- assert.rb : add
- TestCase#teardown : call restore_original_env
- Command#exec : add argument for a command
- test_cmdunit.rb : use File::expand_path for __FILE__