Generating an executable test

Follow this procedure to generate an executable test. Before a test can be run, the test's Java™ source code must be generated and compiled. This process is called code generation.

About this task

Before the test's Java code can be generated, a location for storing the code must exist. By convention, this is a folder named src located in the same Java project as the test. If no source folder named src exists in any existing Java project, you must create one as explained in Java Build Path. Once the test's Java source code is generated, the Eclipse IDE automatically compiles the source code into an executable test.

To generate a test's source code, you must complete the following steps:

Procedure

  1. In the Test Navigator of the Test Perspective, right-click the test to be run and select Generate Source.... The JUnit Test Definition Code Generation dialog box opens.
  2. In the Source Folder field, accept the default or click Browse to select the source folder in a Java project in which to store the test code.
  3. In the Package Name field, accept the default or click Browse to select the package in the selected Java project in which to store the test code.
  4. In the Class Name field, specify the name of the test code.
  5. Click Finish.

Feedback