Yahoo UI を使うと JavaScript のユニットテストが非常に簡単にできます。 サンプルは、以下のページを参考にして書いたものです。※1 Getting Started with JavaScript Unit Testing and YUI Test 用意するものは以下の3つ テスト対象の JS ファイル テストを書いた JS ファイル テストを実行する HTML ファイル ここでは上から、簡単な足し算をする add.js、add-test.js、unittest.html を用意しました。 add.js /** * 簡単な足し算関数。arg1 と arg2 の合計を返す。 * 引数が未指定又は、非数値の場合、結果は NaN になる。 */ function add(arg1, arg2) { arg1 = arg1 ? arg1 : NaN; arg2 = arg2 ? a