Using a Modular Approach: Exercise: Making the Names Test Modular


Now that you know how to redesign a long script into several modules, try this out with the TestNames test from the last chapter's exercise. If you didn't do that exercise, you can find the solution (TestNames.java and TestNames.java) in the \tutorial\gettingStarted directory.

Instructions

For this exercise:

  1. Compose a multi-node JST to test the names window.

  2. Record the scripts that correspond to each node.

  3. Integrate the JST for Names into a copy of the acceptance test. Name this copy Acceptance2.jst, so that you don't confuse it with the original version.

  4. Run the test to make sure it works.

Solution

There's more than one way to tackle this exercise. One solution breaks the search test down into four modules:

You might have chosen fewer, and that's okay. Using four modules comes in handy later on, when you can parameterize individual nodes.

If you did use four nodes, your search JST in the Test Composer should look somewhat like this:

VerifyNames.jst

Incorporating the VerifyNames JST into the acceptance test requires only a few steps. You only need to:

  1. Open Acceptance.jst in the Test Composer.

  2. Add a node for VerifyNames.jst (or whatever you named your Names test).

  3. Draw a normal, green arrow from ClearDisplay to VerifyNames.jst.

  4. Save the results as Acceptance2.jst.
    The Acceptance2.jst work area should have looked similar to this:

    Acceptance2.jst--one solution

When you run this test, the summary for the overall Acceptance2.jst run should show 12 verifications instead of the original six.

You can find VerifyNames.jst and the scripts that support it in the \tutorial\modular directory. Look at the files:

VerifyNames.jst
OpenNames.class
and OpenNames.java
SelectName.class
and SelectName.java
VerifyRecord.class
and VerifyRecord.java
CloseNames.class
and CloseNames.java
Acceptance2.jst




Send feedback to JavaStar-feedback@suntest.com
Copyright © 1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303. All rights reserved.