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