Chapter 6. Coarse-grained testing with stubs

 

And yet it moves.

Galileo

This chapter covers

  • Introducing stubs
  • Using an embedded server in place of a real web server
  • Unit testing an HTTP connection with stubs

As you develop your applications, you’ll find that the code you want to test depends on other classes, which themselves depend on other classes, which then depend on the environment. For example, you might be developing an application that uses JDBC to access a database, a Java EE application (one that relies on a Java EE container for security, persistence, and other services), an application that accesses a file system, or an application that connects to some resource using HTTP, SOAP, or another protocol.

In the previous chapters, we introduced the JUnit framework. Starting in this chapter, we look at using JUnit to test an application that depends on external resources.

6.1. Introducing stubs

 
 

6.2. Stubbing an HTTP connection

 
 

6.3. Stubbing the web server’s resources

 
 

6.4. Stubbing the connection

 
 
 

6.5. Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage