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.

  1. Create a new plug-in project called com.packtpub.e4.junit.plugin.
  2. Create a new JUnit test called PlatformTest in the com.packtpub.e4.junit.plugin package.
  3. Create a method, testPlatform, which ensures that the Platform is running:
    @Test
    public void testPlatform() {
      assertTrue(Platform.isRunning());
    }
  4. Click on the quick-fix to add org.junit to the required bundles.
    1. Alternatively, open up the project's manifest by right-clicking on it and choosing Plug-in Tools | Open Manifest.
    2. 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.