Mock Object Testing Using JUnit, StrutsTestCase, and Ant

This section is based on the file that’s included on the CD-ROM that accompanies this book. Other sections of this chapter use different archives.

The first test you create is a simple mock object test for the Hello World application.

How do you know where to begin and what to test? The easiest way is to look at the code you need to test and just start there. To begin, here’s a snippet from the file:

// If this is first time, go straight to page
        String action = request.getParameter("action");
        if (action == null) {
            return (mapping.findForward("SayHello"));

This code snippet is near the beginning of the execute method in the HelloAction class. This code ...

Get Struts Kick Start now with O’Reilly online learning.

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