New Test For Existing Class Wizard: Existing Class To Test
See Also
The New Test For Existing Class wizard creates a new JUnit test class in the specified test folder.
When you create a test for an existing class you specify the class that you want to test
and the IDE generates a test class that contains skeleton methods based on the methods in the specified class.
You open the New Test For Existing Class wizard by selecting Test for Existing Class in the JUnit category of the New File wizard.
In the Existing Class To Test panel, you set the following properties:
- Class to Test. Click Browse to locate the class you want to test.
- Created Test Class. Specifies the class name of the test.
The default name is based on the name of the class you are testing, with the Test appended to the name.
- Project. Specifies the project where the test is located. You cannot change this value.
- Location. Specifies the test folder where you want to create the test.
The drop-down list contains all folders specified as project test folders.
- Created File. Displays the path to the new file. The name of the file is identical to the class name.
- Method Access Levels. Select the checkbox if you want the IDE to generate test skeletons for the following types of methods:
- Public. When selected the IDE will generate test skeletons for public member methods.
- Protected. When selected the IDE will generate test skeletons for protected member methods.
- Package Private. When selected the IDE will generate test skeletons for default member methods.
- Generated Code. Select the checkbox if you want the IDE to generate the following:
- Test Initializer. Method for tasks like initializing fields,
enabling on logging, and resetting environment variables.
- Test Finalizer. Method for cleaning up after tests have finished running.
- Default Method Bodies. Sample test code and instructions for printing out information about
test status to the command output.
- Generated Comments. Select the checkbox if you want the IDE to generate the following:
- Javadoc Comments. Javadoc comments in the generated code for the test methods.
- Source Code Hints. Hints in the generated code that suggest how to implement the test methods.
When you click Finish the IDE creates the test class based on the parameters you have specified and opens the class in the editor.
The test class then appears in the Projects window in the test folder.
The IDE creates the test class under the package-name node
that replicates the package structure of the tested class.
- See Also
- Creating a JUnit Test
- Running a JUnit Test
- About JUnit
Legal Notices