PDE provides JUnit support for testing plug-ins by contributing a JUnit Plug-in Test launcher to the SDK. As with all other launchers in Eclipse (e.g. the Java Application and Java Applet launchers,...), the JUnit Plug-in Test launcher can be invoked via a shortcut and its launch configurations are centrally managed in the Launch Configuration Dialog.
When a JUnit Plug-in Test launch configuration is launched, a lightweight PDE application is the main entry point to the runtime Eclipse instance. If the application being tested by the user requires a user interface, the PDE application spawns the workbench for that application. Once the workbench is up, the test harness runs inside the workbench. After all tests are run, the PDE application closes the workbench and exits; thus, terminating the test run.
If the tests being run do not require a user interface (i.e. headless mode), then the lightweight PDE application runs the test without launching a workbench. After all tests are run, the PDE application exits.
Refer to the Main tab of the JUnit Plug-in Test launch configuration for details on how to run the different types of tests.
A quick way to run a JUnit plug-in test is via the Run As > JUnit Plug-in Test from the context menu of a plug-in project. To launch in debug mode, choose Debug As > JUnit Plug-in Test from the context menu of the plug-in project. These actions are also available in the context menus of source folders, packages, source files and methods inside a plug-in project.
When creating a new launch configuration via a shortcut, PDE examines the dependencies of the enclosing plug-in. If the plug-in requires the org.eclipse.swt plug-in directly or indirectly, then the launch configuration that is created is customized to run UI tests; otherwise, the launch configuration is customized to run headless tests.
In order to have full control over launching a JUnit Plug-in Test, you can create and customize a launch configuration in the Launch Configuration Dialog.
The Launch Configuration Dialog can be invoked via Run > Run... or Debug > Debug... from the top level menu. A new JUnit Plug-in Test launch configuration can be created by double-clicking on the JUnit Plug-in Test node in the tree viewer to the left.
A JUnit Plug-in Test launch configuration contains eight tabs allowing you to customize all aspects of the test launch. Refer to the following documents for more details: