JavaScriptをユニットテスト XUnitの中のひとつとしてJsUnitがあります。 文字通りJavaScriptをユニットテストできるシロモノなのですが、JavaScriptのライブラリが台頭するこのご時世、自らも濃いJavaScriptを書く方も多いのではないでしょうか?実際どんな感じで書いていけるのかTDDと絡めてざっくりとまとめてみます。 テストケースの書き方 今回は引数が空であるかをチェックするisEmpty関数を実装してみることにします。 TDDに習ってまずはテストケースから書いてみましょう。JsUnitのテストケースはhtmlで書きます。例えばこんな感じ。 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html