Before you begin, you must complete Exercise 1.1: Creating a test project..
After you create a test project, you can use the Create Java Component Test wizard to create Java component tests and stubs. If you need to test a Java interface, abstract class, or superclass, you can also create a special kind of component test called an abstract test.
In this example, the wizard takes you through the following steps:
To start the wizard:
After you select a test project, a static analysis is performed on the Java source files associated with the test project. These files were selected during the creation of the test project and serve to define the scope of the test. The list of files in the project can be updated by modifying the test project's Test Scope properties.
When the analysis is complete, you will see a list of components in a table format and sorted according to the computed metrics. You can use the guidance that these metrics provide to help you decide which classes or components are most important for you to test. Components with highlighted values or high numerical values are considered high-priority test candidates.
In the following figure, for example, GaussianIntegerRandomGenerator would be one place to start, so to test this class, simply click the check box next to GaussianIntegerRandomGenerator and click Next. (You can also click Options to modify which metrics are displayed and to change the sort order.)
After you select the classes you are going to test, you need to select a test pattern. Test patterns provide a sort of template for different kinds of Java component tests. The available test patterns for Java components include:
For your first test, select the scenario-based test pattern and click Next.
After you select the test pattern, you will see a wizard page that lets you define the test scenario. The process is as follows:
When you create a scenario-based test, a single test case is created within the test suite. In the test behavior code, the test case is implemented as a single JUnit test method. After you finish creating the test, the Overview page of the Test Suite editor is displayed automatically, as shown below:
From this page, you can edit the name of the test, add a description of the test, and open the test behavior code in the Java editor. To view the code, click the Behavior (/StatTest/Behavior/test/GaussianIntegerRandomGeneratorTest.java in the example above).
Now you are ready to begin Exercise 1.3: Editing the test.