Chapter 9. Unit-testing servlets and filters

This chapter covers

  • Demonstrating the Test-Driven Development (TDD) approach

  • Writing servlet and filter unit tests with Cactus and mock objects

  • Running Cactus tests with Maven

  • Choosing when to use Cactus and when to use mock objects

 

The only time you don’t fail is the last time you try anything—and it works.

 
 --William Strong

When you unit-test servlet and filter code, you must test not only these objects, but also any Java class calling the Servlet/Filter API, the JNDI API, or any back-end services. Starting in this chapter, you’ll build a real-life sample application that will help demonstrate how to unit-test each of the different kinds of components that make up a full-blown web application. This chapter ...

Get JUnit in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.