Chapter 8. In-container testing with Cactus

This chapter covers

  • Drawbacks of mock objects when unit-testing components

  • Introducing testing inside the container with Cactus

  • How Cactus works


Good design at good times. Make it run, make it run right.

 --Kent Beck, Test Driven Development: By Example

Starting with this chapter, we’ll study how to unit-test J2EE components. Unit-testing components is more difficult than just testing plain Java classes. The components interact with their container, and the container services are available only when the container is running. JUnit is not designed to run inside a container like a J2EE component. So, how can we unit-test components?

This chapter examines one approach to unit-testing J2EE components: in-container ...

Get JUnit in Action now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.