Unit Testing RCP Applications


Include Unit tests launching and stop in case of failure in a continuous integration process is a MUST. In the case of an Eclipse RCP application continuous environment process (based on ANT and PDE build scripts) set up we have to decide “how to install and launch unit tests“.

Solution: After building the RCP product, install the product using P2 director command line in the Eclipse SDK that has been used to build the product with a specific configuration. Then just launch the PDE unit test application as following:

 <java dir="./plugins" classname="org.eclipse.equinox.launcher.Main" fork="yes" classpathref="equinox.launcher.class.path" maxmemory="512m">
 <arg line="-application org.eclipse.pde.junit.runtime.uitestapplication -port ${port} -testpluginname ${plugin} -classnames ${classes} ${config}" />
 </java>

This solution is great but has a main drawback: We are not running the unit tests in the “final” environment but in an SDK environment that has been enhanced with our RCP product.  A better solution to my eye will be to enhance the RCP product with the few plugins required by PDE unit test application in order to be closest to the final environment when launching the tests.

I’am investigating on that ….. next episode coming soon !

Note: feel free to comment this post to bring your point of view and experiences about RCP unit testing.

About these ads

5 thoughts on “Unit Testing RCP Applications

  1. Hi Manuel,

    At BonitaSoft, we build the RCP product first, then we build the test feature (containing junit fragment and its dependencies, and our test plugins) using the newly build product as “pluginPath”.
    After that, we only unzip the test feature in a copy of our RCP, and can test it.

    Hope this will help you to go further ;)

  2. Hi Mickael, thanks for the quick answer. I am doing the same thing regarding the build (pluginpath). Regarding the unzip of the test feature in the RCP, in my case it doesn’t seems to work and I guess this is related to P2 (my RCP product is build with P2 enabled: p2gathering=true). Is your RCP a P2 one ?

  3. We did not leverage p2 yet (but we should soon to factorize the build of all our plugins to result in a single repo, and extract the different products from it).

    With p2, you can do it almost the same way. The difference is that you’ll invoke the p2 director on your product to install test features instead of unzipping them.

  4. I have after some struggling done this with buckminster and windowtester pro from google utilizing the p2 director.

    short sum
    1. Hudson builds the product via buckminster, as a parallel job it also builds the ui tests as an p2 site.

    2. Hudson publishes the newly built product / ui tests to our stage server visa scp.

    3. Hudson provisions the newsly built director from the stagesite via the p2 director.

    4, Hudson installs org.eclipse test framework, and the wintest pro framework and last our newly built ui tests.

    5. Initialises the product, and kicks off the ui tests, let hudson access the xml output to have the junit pass/fail graph show.

  5. hi….
    when i apply junit to my RCP application which contains the object of bundle context,what should i pass in test case as an object of bundle context.

    Regards
    Ankit

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s