O'Reilly logo

JUnit in Action by Ted Husted, Vincent Massol

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required