The tycho project brings the power and convenience of Maven to Eclipse plug-in development. Having automated the builds for and developed (test-driven) two commercial Eclipse plug-in and RCP applications, I have always found PDE build to be the soft underbelly of the Eclipse armadillo. But I muddled my way through and over time built comprehensive suites of both JUnit microtests and Plug-in integration tests. While tycho's facility for integration tests is particularly impressive, the vast majority of my suites do not need the OSGi runtime, and some, in fact, would break when run as integration tests. In addition, some Eclipse plug-ins are implemented with the intention that they will be used outside Eclipse (EMF, for example) as well as in, and I would imagine that tests for these types of plug-ins would need to run as plain ol' JUnits for certain scenarios. The goal of this entry is to present one possibility for running microtests under tycho without OSGi.
Generate Default Poms:
First, we will need to install tycho. I primarily followed Mattias Holmqvist's instructions, along with a few others, to install Maven 3 (alpha 7), to build tycho from source, and to generate poms from my existing plug-ins and test fragments.
After generating a parent pom in the plugins directory above the individual plug-in and test fragment projects, running integration tests is simple:
Run The Microtests:
Now that we have tycho building our plug-ins and running integration tests, we can modify the generated poms in test fragments which do not need the OSGi runtime. Fortunately, this is only a matter of configuring the surefire plug-in (and adding a JUnit 4 dependency if necessary):
From the plugins directory, running microtests is simple:
With the ability to run JUnit tests for Eclipse plug-ins without OSGi, we are now able to migrate existing projects incrementally to tycho. Hopefully, others who are facing similar problems will find this tutorial useful.