Java Reference
In-Depth Information
In-container testing
The secret of success is sincerity. Once
you can fake that you've got it made.
—Jean Giraudoux
This chapter covers
The drawbacks of mock objects
In-container testing
Comparing stubs, mock objects, and
in-container testing
This chapter examines one approach to unit testing components in an applica-
tion container: in-container unit testing, or integration unit testing. We discuss in-
container testing pros and cons and show what can be achieved using the mock
objects approach introduced in chapter 7, where mock objects fall short, and how
in-container testing enables you to write integration unit tests. Finally, we com-
pare the stubs, mock objects, and in-container approaches we've already covered
in this second part of this topic.
8.1
Limitations of standard unit testing
Let's start with the example servlet in listing 8.1, which implements the Http-
Servlet method isAuthenticated , the method we want to unit test.
126
 
 
 
 
 
 
Search WWH ::




Custom Search