Using Jtest Within VisualAge
After you have integrated Jtest into VisualAge as described in Integrating VisualAge and Jtest, you can use Jtest within the VisualAge IDE to perform any of the following actions:
- Test a single class within a project.
- Test a package.
- Test a project.
- Test a class that uses a class in another project.
- Edit your source code.
- Import Test Classes or Stub Classes.
- Remove exported files.
Testing a Single Class Within a Project
- In the VisualAge IDE, right-click the class that you want to test, then choose Tools> Jtest> Test Class from the shortcut menu. This will export the Project that contains the class and load the class in Jtest's Class Testing UI. The VAJ log window will indicate that it is exporting into Jtest. After the export is complete, the log window will indicate that you must export the class under test's dependencies before you start testing in Jtest.
- To start testing, click Start in Jtest's Class Testing UI.
Testing a Package
- In the VisualAge IDE, right-click the package that you want to test, then choose Tools> Jtest> Test Package from the shortcut menu. This will export the project the class is contained within and load the package path in Jtest's Project Testing UI. The VAJ log window will indicate that it is exporting into Jtest. After the export is complete, the log window will indicate that you must export the package under test's dependencies before you start testing in Jtest.
- To start testing, click Start in Jtest's Project Testing UI.
Testing a Project
- In the VisualAge IDE, right-click the project that you want to test, then choose Tools> Jtest> Test Project from the shortcut menu. This will export the project and load the project path in Jtest's Project Testing UI. After the export is complete, the log window will indicate that you must export the project under test's dependencies before you start testing in Jtest.
- To start testing, click Start in Jtest's Project Testing UI.
Testing a Class that Uses a Class in Another Project
To test a class that uses a class in another project, you need to export the dependencies into Jtest. You can export a single class, a package, or a project.
To export a single class needed for testing:
- Right-click the class in the VisualAge IDE, then choose Tools> Jtest> Export Class from the shortcut menu.
To export a package needed for testing:
- Right-click the package in the VisualAge IDE, then choose Tools> Jtest> Export Package from the shortcut menu.
To export a project needed for testing:
- Right-click the project in the VisualAge IDE, then choose Tools> Jtest> Export Project from the shortcut menu.
When you export a class, package, or project into Jtest, it will be automatically be added to the Jtest classpath. All classes, packages, and projects that you have tested or exported into Jtest will be placed in the following path: <jtest_installation_directory>/u/<your_user_name>/ tmp/va/export/<path to class >
Editing Your Source Code
Whenever you choose to edit your source code from Jtest, Jtest will automatically open the appropriate file in the VisualAge IDE.
When you start a test in Jtest, the package or project being tested is re-exported to capture any changes made when you edited your code within VisualAge.
Importing Test Classes and Stub Classes
To use Test Classes and Stub Classes, you must first import them into your workspace. To do this, choose Workspace> Tools> Jtest> Import Jtest classes from the VisualAge menu bar. This will create a project titled "Jtest classes" and import Jtest classes (Jtest API) in VisualAge's workspace.
Removing Exported Files
After you are done testing, if you want to remove the files that Jtest exported to your file system, choose Workspace> Tools> Jtest> Clean Export Directory from the VisualAge menu bar
Additional Notes on Jtest/VisualAge Integration
- Only files currently in the workspace can be exported.
- When Jtest is started, the project that is being tested (or the project that contains the class or package being tested) is automatically exported to the File System. All the classes must be in the workspace. Classes that are in the repository but not in the workspace will not be exported.
- If a class that you want to test depends on a class or package in another project, you need to perform one of the following steps to export that class, package, or project into Jtest:
- Right-click the class, then choose Tools> Jtest> Export Class.
- Right-click the package, then choose Tools> Jtest> Export Package.
- Right-click the project, then choose Tools> Jtest> Export Project.
- If you change a tested class, package, or project while Jtest is open, you don't need to restart Jtest. When you click Jtest's Start button, the entire project is re-exported and all of the changes in that current project will be captured.
- Jtest behaves as follows to improve testing speed:
- When you right-click a package or project then choose Tools> Jtest> Test Project/Package, Jtest asks you whether you would like to re-export the project/package. If you modified your code since you chose Test Project/Package (and want to test the modified code, choose Yes. Otherwise, choose No.
- Jtest will not collect global static analysis information before you test in the Class Testing UI. This information will still be collected when you test a set of files in the Project Testing UI.
|