ert-expectations: 新世代ユニットテストフレームワーク in Emacs Lisp
お久しぶりです。
世の中はすっかりEmacs24になってきたようですね。
本日、el-expectations.elの後継となるert-expectations.elをリリースしたのでお知らせします。
el-expectations.elは現役で使っているのですが、テストが失敗したときのレポート機能が弱くて不便に思っていました。
Emacs24ではユニットテストフレームワークのERTが標準添付になったことにより、ERTを内部で呼び出すことでその問題を克服しました。
基本的な使い方はel-expectationsと変わりません。
ERTについて学んでなくても今すぐ使えます。
M-x install-elisp-from-emacswiki ert-expectations.el
M-x install-elisp-from-emacswiki el-mock.el
あるいは
M-x auto-install-batch el-expectations
でインストールしてください。
※auto-install-batch-list.elはert-expectations.elを読むように更新しました。
http://www.emacswiki.org/emacs/download/ert-expectations.el
http://www.emacswiki.org/emacs/download/el-mock.el
たとえば、成功するテスト2つと失敗するテスト2つを実行させましょう。
el-expectationsと同じようにS式にてC-M-xを押します。
(expectations (desc "success") (expect 10 (+ 4 6)) (expect 5 (length "abcde")) (desc "fail") (expect 11 (+ 4 6)) (expect 6 (length "abcde")))
すると、*ert*バッファに次のように出力されます。
テスト失敗時のレポートがより詳しく出力されるのです。
Selector: t Passed: 2 Failed: 2 (2 unexpected) Total: 4/4 Started at: 2012-10-09 15:37:17+0900 Finished. Finished at: 2012-10-09 15:37:17+0900 ..FF F erte-test-00003 (ert-test-failed ((should (equal 11 (mock-protect (lambda nil (+ 4 6))))) :form (equal 11 10) :value nil :explanation (different-atoms (11 "#xb" "?^K") (10 "#xa" "?\n")))) F erte-test-00004 (ert-test-failed ((should (equal 6 (mock-protect (lambda nil (length "abcde"))))) :form (equal 6 5) :value nil :explanation (different-atoms (6 "#x6" "?^F") (5 "#x5" "?^E"))))
また、desc式を置いていれば、テスト名(erte-test-00003など)のリンクを辿ればジャンプできます。
その他はel-expectations.elの説明を参照してください。
http://d.hatena.ne.jp/rubikitch/20080409/elexpectations
P.S.
Emacsのネット塾を運営しています。
最新の技術を数分で自分のものにすることができます。
ここで一気にライバルに差をつけてしまいましょう。
週1のメルマガに加え、僕がアドバイザーとなり無制限サポートを行っています。