Recipe 12.4 Testing Plug-ins with the Run-time Workbench


12.4.1 Problem

You are developing a plug-in, and you don't want to keep stopping and starting Eclipse each time you want to test the plug-in.

12.4.2 Solution

Launch a runtime workbench, which opens a new workbench with your plug-in already installed for testing purposes.

12.4.3 Discussion

If you want to, you can build the plug-in created in the previous recipe and deploy it to the plugins directory (see Recipe 12.5). But for testing purposes, there's an easier way. All you have to do while developing a plug-in is to launch a runtime workbench, which will appear with your plug-in already installed.

To launch a runtime workbench, highlight the plug-in project in the Package Explorer, select Run Run, click the Run-time Workbench node in the left pane of the Run dialog, and click the New button, creating a new launch configuration, as shown in Figure 12-9. Accept the defaults by clicking Run.

The next time you want to launch the Run-time Workbench, you can simply select Run Run As Run-time Workbench.

Figure 12-9. Creating a launch configuration

This starts the Run-time Workbench. You can see the menu defined by the plug-in, Sample Menu, and the button (with the Eclipse icon) it adds to the toolbar in Figure 12-10.

If you don't see your plug-in in the Run-time Workbench, select Window Customize Perspective Other, check the "Sample Action Set" checkbox defined by the plug-in we created, and click OK.

Figure 12-10. A runtime workbench

To verify things are working as they should, select Sample Menu Sample Action or click the New button. The plug-in displays a message box with the message This plug-in is functional ., as shown in Figure 12-11.

Figure 12-11. The plug-in's message

Coolyou've now created and run an Eclipse plug-in. To quit, close the Run-time Workbench.

You can debug plug-in code as you'd expect; just select Run Debug As Run-time Workbench. Eclipse 3.0

Eclipse 3.0 offers a new option on the Plug-ins tab of the Run-time Workbench launch configuration dialog that enables you to select a set of plug-ins to include while testing your plug-in. And as far as testing goes, the Eclipse 3.0 PDE has a new launcher for JUnit-based unit test suites for plug-ins. In fact, that's one of the big changes in Eclipse 3.0: you can use JUnit to test plug-ins.

Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: