O'Reilly logo

Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications by Mick Knutson

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

Using Mock objects for testing

In order to properly execute a unit test, you must be able to create an isolated unit of work that can be measured in isolation. When you are attempting to isolate portions of a Java EE application, you quickly find there are many supporting services and external systems that a Java EE application requires, but which can interfere with isolation. In order to enforce test isolation, you can introduce Stubs and Mocks into your tests. In the recipe for DBUnit testing, we saw how there can be many complexities in seeding data for external systems such as databases, to ensure consistent and reliable tests. Introducing Mock objects can aid in reducing the complexity of testing, and help foster isolated testing.

This recipe ...

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