CmdUnit

yuichi TAKAHASHI
$Id: index-ja.html,v 1.2 2002/03/29 15:26:54 yuichi Exp $


Table of Contents


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. バグレポート

mailto:yt@xpenguin.biz


6. 変更履歴

20010606-alpha -> now