Although Java projects and Java plug-in projects both use Java and JUnit to execute, plug-ins typically need to have access to them (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 called
testPlatform()
, which asserts that thePlatform
is running:@Test public void test() { 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 going to Plug-in Tools | Open Manifest.
Go to the Dependencies tab and 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 and going to Run As | JUnit Test. You will see the error...