Chapter 13. Testing and Debugging

Introduction

You can write the coolest Struts applications in the world, but if you don’t know how to test them, or you can’t seem to debug them, you might as well not have written them in the first place. Testing and debugging web applications can be a frustrating experience. If you test your application by deploying it to your application server and “banging on it,” then the recipes in this chapter will provide some techniques that are worth learning. If your only approach to debugging involves sticking System.out.println( ) in places where you think the problem might be, then you’ll definitely want to check out some of these solutions.

The key to debugging an application is visibility; the more information you have about the internal workings of the application, the easier it can be to pinpoint the problem. The chapter has solutions that show you how to monitor what your application is doing. This first half of this chapter presents some solutions related to logging and debugging that will help you understand what’s going on inside your application.

The heart of testing and debugging is the unit test. A unit test verifies that a specific portion of your application does what it is supposed to do. Java developers commonly think of the “unit” as a Java class. But the unit can be anything as long as it can be identified by discrete boundaries and isolated from code external to the unit. This chapter has two recipes that show you how to unit test ...

Get Jakarta Struts Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.