Chapter 10. Integration testing

 

This chapter covers

  • Maven configuration for Spring integration testing
  • Writing transactional happy-path tests
  • Creating exception and performance tests

Ideally, testing is a core activity of the practicing software developer, and it so happens that the dependency-injection approach to software design is especially useful in the testing arena. Dependency injection is particularly useful in unit testing, where you desire to test small units of code in isolation from other code. With dependency injection you can inject mock dependencies with prescribed behavior into code units, which allows you to isolate faults to the code under test.

A step up from unit testing is integration testing. The idea here is to test collaborations between units of code. An integration test can be fairly narrow, perhaps involving a single collaboration between a web controller and a service bean (with DAO dependencies mocked out). At the other extreme it can involve deploying the code under test to a servlet container (or other container), sending HTTP requests and parsing HTTP responses for the expected output.

This chapter presents Spring’s TestContext framework, which offers features useful for both unit and integration testing. Here we’ll focus on integration testing because the features in this area are especially powerful.

10.1. Configuring Maven for integration testing

 
 
 
 

10.2. Writing transactional happy-path integration tests

 
 
 
 

10.3. Verifying that code under test throws an exception

 
 

10.4. Creating integration tests that verify performance

 
 
 

10.5. Ignoring a test

 
 

10.6. Running integration tests against an embedded database

 
 

10.7. Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest