Reputation: 121762
I'm working on a eclipse plug-in and I've tried to create another test project seperate from the plug-in. The reason I do this is to not let the plug-in depend on jUnit when it is exported. However, I can't access the Eclipse Plug-in API when I do the testing. Whenever I try to add Plug-in dependencies the import list to that is empty.
Does anyone know how to import Eclipse plug-in API to an existing project? The workspace layout looks like this at the moment:
+- com.foo.myplugin
| |
| +- JRE System Library
| |
| +- Plug-in Dependencies
| |
| +- src
| |
| +- icons, META-INF, plugin.xml, etc...
|
+- com.foo.myplugin.test
|
+- JRE System Library
|
+- JUnit 4
|
+- src
Upvotes: 6
Views: 2912
Reputation: 121762
You can export the plug-in dependency from the plug-in project. Easiest way is like this:
Go to your com.foo.plugin
project properties
Go to Java Build Path > Order and Export
Check the Plug-in Dependencies entry
The test project should now be able to use plug-in API without the need to use all plugin configuration required for a plug-in project.
Upvotes: 3
Reputation: 16823
The recomended way of ding this seems to be with Plug-in fragments:
http://rcpquickstart.com/2007/06/20/unit-testing-plug-ins-with-fragments/
The fragment gets a high-degree of access to your plugin's code and separates the testing logic / dependencies from the plugin itsself.
Now if only I could find a way to test them in an automated system... (see: Automating unit tests (junit) for Eclipse Plugin development )
Upvotes: 7
Reputation: 1323753
You could try to add the plugin nature to your new myplugin.test project.
In your .project file:
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
[...]
</natures>
Then in the .classpath, add:
<classpath>
[...]
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
[...]
</classpath>
Delete your myplugin.test from the workspace, re-import that project and see if that does the trick...
Upvotes: 0