Exercise 1.1: Creating a test project

Component test projects serve as a grouping mechanism for the test artifacts that you create using the automated component testing features. Test projects also serve to define the scope of the test project by limiting the number of files that will be analyzed when you create tests or stubs, especially when you have many projects or large projects in your workspace. The test project is linked to one or several Java projects that contain the components you want to test.

To create a new component test project:

  1. From any perspective, click File > New > Project > Component Test > Component Test Project and click Next.
  2. If you receive the Confirm Enablement dialog, click OK to enable the component test capability.
  3. In the Create a Component Test Project wizard page, supply a name for the project and click Next to accept the default storage location or uncheck the Use default check box, specify a desired location, and click Next.
  4. In the Define the Scope of Component Test Project page, select the components that can be used to create tests or stubs within this project and click Finish.
  5. If prompted to change to the Test perspective, click Yes.

The new test project is displayed in the Package Explorer view of the Java™ perspective and the Test Navigator view of Test perspective.

Note:  When you create the component test project, the Java build path is updated to include the component test libraries. These libraries include the JUnit and IBM component test support JAR files. If you experience class path errors at any point while working through these examples, verify that these libraries are configured properly. To view the Java build path, right-click the test project in the Test Navigator, click Properties, and then click Java Build Path.

Test projects contain both execution-oriented artifacts (test runs and test suites) and code-oriented artifacts (test behavior scripts and stubs). The execution-oriented artifacts are viewed in the Test Navigator, while the code-oriented artifacts are viewed in the Package Explorer.

Test Navigator Package Explorer

Before moving on to the next exercise, lets make sure you understand what these artifacts are.

A run is an artifact that gets created when you run a test. A run is the consolidated results of one test execution and may incorporate several test suites, test cases, and individual tests.

A test suite is a grouping mechanism that is used to organize the artifacts that get created when you create test projects and tests. A test suite contains test cases, stubs, and test deployment data.

A behavior is the actual Java source code that is created at the time of test generation.

A stub is a class that is used as a replacement for a class that interacts with the class under test.

To simplify your work with component testing, you can add the Package Explorer view to the Test perspective. To do this, go to the Test perspective; then click Window > Show View > Other > Java > Package Explorer.

Now you are ready to begin Exercise 1.2: Creating a Java component test.

Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.