In this talk we want to share some tips and tricks on how to test Eclipse plug-ins at several stages during the development. In particular, we will show how to do without a running workbench (i.e., “Plug-in tests”) and without functional testing frameworks (e.g., SWTBot) as much as possible, relying only on plain JUnit tests.
Indeed, many important parts of the components of an Eclipse plug-in can be tested with a plain JUnit test. Note that we are not talking only about core, non UI, parts: even those parts that need SWT or Jface (e.g., label and content providers, tree and table viewers) can be almost entirely tested without an Eclipse workbench (for most tests, you don’t even need a Display). With that respect, we will show some testing utility classes that can be reused in your projects. We will also show some examples of mocking to make tests cleaner and to be able to test even corner case situations. Using plain JUnit tests as much as possible has the huge advantage of making your software much easier and much faster to test (we’re talking about seconds instead of several minutes).
Then we will also show when to write “Plug-in tests”, in order to test the features that actually need a running workbench; in this case, we will follow a programmatic approach and we will then switch to a functional testing framework (e.g., SWTBot) when we really need to test the actions that a user would perform on our Eclipse plug-ins. Finally, we will also write (end-to-end) tests on a fully provisioned product (being that a custom Eclipse product or a standard Eclipse installation with our plug-ins installed).
The talk will use simple examples and all the techniques and source code will be easily reusable in other Eclipse projects. Maven/Tycho will also be used to show the execution of tests in a CI system. All the presented techniques have been successfully used to test all the aspects of our Eclipse project EMF Parsley.