Time for action – writing a plug-in test
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 ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.