O'Reilly logo

Struts Kick Start by Kevin Bedell, James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mock Object Testing Using JUnit, StrutsTestCase, and Ant

This section is based on the strutsJUNIT.zip 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 HelloAction.java 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required