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 – avoiding SWTBot runtime errors


Once more test methods are added, the runtime may start throwing spurious errors. This is because the order of the tests may cause changes, and ones that run previously may modify the state of the workbench. This can be mitigated by moving common setup and tear-down routines into a single place.

  1. Create a static method beforeClass.

  2. Add the annotation @BeforeClass from the org.junit package.

  3. Move references to creating a SWTWorkbenchBot to the static method, and save the value in a static field.

  4. The code looks like:

    private static SWTWorkbenchBot bot;
    @BeforeClass
    public static void beforeClass() {
      bot = new SWTWorkbenchBot();
      try {
        bot.viewByTitle("Welcome").close();
      } catch (WidgetNotFoundException e) {
        // ignore
      }
    }
  5. Run the tests and ensure that they pass appropriately.

What just happened?

The JUnit annotation @BeforeClass allows a single static method to be executed prior to any of the tests running in the class. This is used to...