Although Java projects and Java plug-in projects both use Java and JUnit to execute, plug-ins typically need to have access provided by the runtime platform, which is only available if running in an OSGi or Eclipse environment.
Create a new plug-in project called
com.packtpub.e4.junit.plugin
.Create a new JUnit test called
PlatformTest
in thecom.packtpub.e4.junit.plugin
package.Create a method,
testPlatform
, which ensures that thePlatform
is running:@Test public void testPlatform() { assertTrue(Platform.isRunning()); }
Click on the quick-fix to add
org.junit
to the required bundles.Alternatively, open up the project's manifest by right-clicking on it and choosing Plug-in Tools | Open Manifest.
Go to the Dependencies tab, click on Add, and select
org.junit
from the dialog.Ensure that
org.eclipse.core.runtime
is also added as a dependency.
Run the test by right-clicking on the project, choosing Run As | JUnit Test and seeing the error message fail with...