9 In-container testing

 

This chapter covers

  • Analyzing the limitations of mock objects
  • Using in-container testing
  • Evaluating and comparing stubs, mock objects, and in-container testing
  • Working with Arquillian

The secret of success is sincerity. Once you can fake that you’ve got it made.

--Jean Giraudoux

This chapter examines one approach to unit testing components in an application container: in-container unit testing, or integration testing. These components are modules that may be developed by different programmers or teams and that need to be tested together or integrated. We will analyze in-container testing pros and cons and show what you can achieve by using the mock-objects approach introduced in chapter 8, where mock objects fall short, and how in-container testing enables you to write integration unit tests. We will also work with Arquillian, a Java EE container-agnostic framework for integration testing, and show you how to use it to conduct integration testing. Finally, we will compare the stub, mock-object, and in-container approaches covered in this part of this book.

9.1 Limitations of standard unit testing

9.2 The mock-objects solution

9.3 The step to in-container testing

9.3.1 Implementation strategies

9.3.2 In-container testing frameworks

9.4 Comparing stubs, mock objects, and in-container testing

9.4.1 Stubs evaluation

9.4.2 Mock-objects evaluation

9.4.3 In-container testing evaluation

9.5 Testing with Arquillian

Summary