Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By : Alex Blewitt
Book Image

Eclipse Plug-in Development Beginner's Guide - Second Edition

By: Alex Blewitt

Overview of this book

Eclipse is used by everyone from indie devs to NASA engineers. Its popularity is underpinned by its impressive plug-in ecosystem, which allows it to be extended to meet the needs of whoever is using it. This book shows you how to take full advantage of the Eclipse IDE by building your own useful plug-ins from start to finish. Taking you through the complete process of plug-in development, from packaging to automated testing and deployment, this book is a direct route to quicker, cleaner Java development. It may be for beginners, but we're confident that you'll develop new skills quickly. Pretty soon you'll feel like an expert, in complete control of your IDE. Don't let Eclipse define you - extend it with the plug-ins you need today for smarter, happier, and more effective development.
Table of Contents (24 chapters)
Eclipse Plug-in Development Beginner's Guide Second Edition
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 Dependencies tab, click on Add, and select org.junit from the dialog.

    3. Ensure that org.eclipse.core.runtime is also added as a dependency.

  5. Run the test by right-clicking on the project, choosing Run As | JUnit Test and seeing the error message fail with...