JUnit Pocket Guide

JUnit Pocket Guide: Quick Look-up and Advice

JUnit Pocket Guide: Quick Look-up and Advice

オライリーのPocket GuideシリーズにJUnit版が出ました。実はKent Beckの著作です。からさわぎでちょっと読んでいたら早速dotたんとkakudaさんに捕捉されたようなので、ここで紹介します。


この本は凄くお薦めです。Pocket Guideシリーズというとその用途からコマンドやAPIや使用法が列挙されていることが多いのですが、JUnitは何しろ非常に小さいフレームワークなので書くことが限られます。その代わりにこの本の半分を占めているのが、Kent Beckのテストに関する考え方やテストの価値などを短く述べた文章たちです。そしてこの文章たちの一つ一つがすごく印象的なのです。以下印象に残った言い回しを引用してみます。

Anxiety harms the rest of my professional activities. When I'm confident, I design better. (snip) When I'm feeling confident, I'm much more aware of other people -- thier moods, words, and ideas. (snip) When I program test-first I can have confidence throughout the process.

If developers are more efficient writing automated tests, there is no tradeoff. Frequent testing doesn't cost; it pays.

So intead of writing tests months after the code is "complete", we can write tests days or hours or minutes after the possible introduction of a defect. Why stop there? Why not write tests a little before the possible introduction of a defect?

When I was in school, I was always taught to think about interface and implementation separately. No one ever said how. Test-first programming is a pragmatic way to separate your thinking about implementation and interface. While you are writing the test you are thinking about interface -- what does this object look like from the outside.

but inheritance is just a tool to help us realize our goals, not an abstract philosophical mechanism.

The test-infected spend less time debugging and more time designing; less time implementing and more time thinking about what they are doing.

このような文章たちがそこかしこにまだまだ沢山散らばっている本だということです。


またStory of JUnitという章に、JUnitの誕生の時のことが書いてあります。Erich GammaとKent BeckがOOPSLAに行く道すがらにJUnitは生まれたようです。(3時間でベースが出来たと書いてあります)。その様子が、

What could be more natual to a couple of geeks in cramped quarters than to pull out a laptop and start coding?

いやぁ、かっこいいなぁ。


最後はTest Infectectionの章で締め。たった90ページ足らずの本なのに満足度が高い本です。小さい本なので私はかばんに入れたり服のポケットに入れたりして持ち歩いています。

  • Automating Tests
  • Why Test?
  • Test-First Programming
  • Stubs
  • Other Uses for Tests
  • Story of JUnit
  • Test Infection

などの章が読みごたえがあります。値段も10ドル足らず。とにかくお薦めの本です。