After reading this chapter, you should have an appreciation of the important role testing has to play throughout the software development lifecycle. The testing activity is more than a backstop at the end of the project for catching defects. It is critical to rapid application development, which can be greatly facilitated by putting in place an automated unit test suite for the project. The presence of this test suite and the adoption of a test-driven approach to development offers two major benefits:
Unit tests also reduce the time it takes to resolve a defect, since unit tests make it easily reproducible. Furthermore, adopting a test-driven approach helps instill the importance of testing for producing quality software within the project team.
In the next chapter, we keep the focus on the testing effort but broaden the scope to include tools and techniques for automating the process of conducting functional and load-based testing.
The process of writing unit tests has gathered a critical mass of knowledge thanks to the large take up of JUnit, and a set of best practices has emerged from the wider developer community for writing effective units tests. To find out more about the intricacies of automated unit testing, the JUnit site found at http://www.junit.org is an excellent starting point and provides an extensive set of links to literature on the subject.
Kent Beck has published a book, Test Driven Development by Example [Beck, 2002], on test-driven development that illustrates the entire process with a complete example.
For more details on mocks, the uncontested home of mock objects on the Web is http://www.mockobjects.com. The site provides an extensive amount of information on anything and everything relating to mock objects.