How to write JUnit plugin tests
Some plugins require e.g. the workspace to be intialized (for access to Projects/Resources etc). This is a step-by-step guide for this.
- Install the target platform or your tests will fail.
- Write JUnit tests in a dedicated test-plugin
- you might need to add the plugin 'org.eclipse.jdt.junit4.runtime' to the manifest. I don't know why this is needed. Please update here if this is outdated!
- Right-click the test, Run as > JUnit Plugin-test
Eclipse might try to start the Eclipse platform with your test (and not Bioclipse), this is not what we want. To resolve:
- Open Run dialog and select the created run config under JUnit Plugin tests
- On the Main tab, select the product to be 'net.bioclipse.ui.product'
- On the Plugin tab, select in combo "plugins selected below only"
- Deselect all plugins, select the plugin that contained your test, uncheck the two checkboxes below, and add required plugins
- I always need to set target platform before running a junit plugin test. Others don't require this. Could be a hint if it fails for you.