Testing Java code is increasingly a task taken on by developers rather than
separate teams to which the programs are handed. Many Java developers are now
familiar with JUnit and know the different between unit tests and integration
tests. This has been driven largely by the focus on test-driven development
(TDD) in extreme programming (XP) and other agile software development
methodologies. While the industry-at-large has recognized the value of unit
tests and has a new outlook on testing in general, for the most part, actual
TDD (meaning, the tests are written first) is not usually practiced outside
of hardcore agile shops.
In this article, we'll present a specific example (based on a real-world
scenario that we recently faced) and walk step-by-step how to take a pure TDD
approach and hopefully show the benefits of embracing TDD completely in this
scenario. (For a... (more)