Chapter 9. Automated Testing of Plug-ins

JUnit is the testing framework of choice for Eclipse applications, and can be used to run either pure Java tests or plug-in tests. If user interfaces need to be exercised, SWTBot provides a facade onto the underling Eclipse application, and can be used to drive menus, dialogs and views.

In this chapter, we will do the following:

  • Create a JUnit test running as pure Java code
  • Create a JUnit test running as a plug-in
  • Write a UI test using SWTBot
  • Interrogate views and work with dialogs
  • Wait for a condition to occur before continuing

Using JUnit for automated testing

One of the original automated unit testing frameworks, JUnit has been in use at Eclipse for over a decade. Eclipse's quality can be partly attributed to the set of automated unit tests that exercise both UI and non-UI (headless) components.

JUnit works by creating a test case with one or more tests, which usually correspond to a class or methods respectively. Conventionally, test classes end with Test, but this is not a requirement. Multiple test cases can be aggregated into test suites, although implicitly a project becomes its own test suite.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset