Tycho Surefire Test Setup Tips

I’ve been helping the CDT project setup some of there build for an eventual migration to Tycho and Maven.  The CDT org.eclipse.cdt.core.tests bundle has a large legacy test suite in it.  It also is highly dependent on the TestSuite method from JUnit 3.   However, with Tycho, it is actually better to NOT use a test suite.    Tycho itself will look for Tests to run based on the following default patterns:

*/Test*.java, **/*Test.java and **/*TestCase.java

**/Abstract*Test.java**/Abstract*TestCase.java and **/*$*

However CDT uses a LOT of Test Suites, and they do some really funky setups at times.

For the most part I have been able to setup the following pattern:

    <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256M</argLine>
      <exclude>**/CDescriptorOldTests.*</exclude> <!-- Seems to take a LONG time with Tycho (maybe hung). -->

The important parts are the include and excludes. These tell Tycho what files should be run and what shouldn’t be run. TestSuites can be handy but they can also be disastrous. Too often, programmers add a test, but forget to also add it to the TestSuite. Thus the test is never run during a build. In the above case, I’m sure I’m missing a few tests, but they can either be renamed (preferably following the standard Tests inclusion pattern), or they can be included specifically into the configuration file.

The other thing to note, Eclipse’s test runner from PDE tends to run the tests in the order they are specified. Tycho Surefire doesn’t run the tests in the same order as the Eclipse Test Runner does. So if your tests are dependent on order, or data from a prior test suite, you will need to re-address this testing smell. Tests should never depend on the result of other tests. So make sure that good setup and tear down practices are being employed.

Following a few basic rules on how you name your tests, and how they are executed, will greatly save you some frustration when migrating your build to use Tycho. Tycho is way more picky about how your project is setup than PDE Build. A lot of configuration file mistakes that PDE Build ignores, Tycho will complain about.

This entry was posted in eclipse, maven, tycho. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s