shUnit
突然 Shell Script で Unit Test をしたくなり、shUnitを見つけたけどしっくりこなかったので、「JUnitみたいにやりたいんじゃー」とか言いながら「Rubyを256倍使うための本 極道編」とまさーるのページ、「バグがないプログラムの作り方」を見比べながらえいやっと作ったのが一年前。
$ ./shUnit usage: shUnit [command] [target-script] [options] commands: generate [target-script] ex) $ ./shUnit generate example.sh run [target-script] [ all | suite | function-name ] ex) $ ./shUnit run example.sh all
スクリプト書くか、と思ったら
$ ./shUnit generate script.sh scriptTest.sh not found. Creating... $ ./scriptTest.sh ##### Test Results Report ##### Test Target: script.sh started to run 1 tests: sample F dummyTest:expected but was: 1 tests, 1 assertions, 1 failures, 0 errrors. real 0m0.090s user 0m0.020s sys 0m0.070s
という感じに雛形を作って、関数を足していくことで Unit Test ごっこができるという仕掛け。
最初は、完成したらどこかでこっそり公開しようかと思ってたんだけど、shUnit 自体のテストを作るところでハマったり、ほとんど同じ発想のshUnit2を発見したり、で結局仕上げるのはあきらめた。
昨日の Ruby クックブック読書会で rubyunit の話を聞いて懐しくなったので、久しぶりに中身に手を入れてみるかな。不出来な子なりに可愛いので、自分では使い続けるつもりだし。