12.6 Summary


12.6 Summary

This chapter described testing of servlet-based Web applications on three different layers:

  • Functional tests, using HttpUnit, involve only those pages of a Web application that can be addressed over HTTP.

  • White-box integration tests on the server, using Cactus, participate in the execution of servlets and JSPs, and allow access to the internal objects of the servlet API.

  • Server-independent tests, using dummy and mock objects, allow testfirst development of servlets.

Function tests for a Web interface are required in all of these cases, whereas there is a choice of different testing technologies. To create expensive integration tests, like those supported by Cactus, it appears worth-while to wait until we actually hit recurring deployment and integration problems. However, this optimistic waiting means that there is a reassuring test suite handily available for the single servlets.

In addition, this chapter introduced an approach on how to separate a servlet's logic from the servlet API to improve testability. Finally, we discussed several ways to generate HTML and how to test this code.

This chapter showed that test-first development is also possible for Web applications. Once more, we noticed that the use of mock objects can contribute to decouple classes and thus to improve the design.




Unit Testing in Java. How Tests Drive the Code
Unit Testing in Java: How Tests Drive the Code (The Morgan Kaufmann Series in Software Engineering and Programming)
ISBN: 1558608680
EAN: 2147483647
Year: 2003
Pages: 144
Authors: Johannes Link

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net