Skip to main content
Jump to: navigation, search

Automated PDE JUnit Testing With Eclipse 3.3M5


After 3.3M4, Modeling builds no longer ran their JUnit tests, due to changes in the way Eclipse packages its startup jars. I had thought the fix was trivial, but unfortunately there's more to it than is explained below. I'll update this document when I find a solution.

[echo] Running org.eclipse.someproject.tests.AllTests
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/launcher/Main
- or -
[echo] Running
[java] Unable to access jarfile {dd}/2.3.0/N200701240200/testing/N200701240200/testing/target/eclipse/startup.jar
- or -
[exec] eclipse-test:
[exec]      [echo] Running org.eclipse.ocl.uml.tests.AllTests
[exec]      [java] java.lang.NullPointerException
[exec]      [java] 	at org.eclipse.equinox.launcher.Main.takeDownSplash(
[exec]      [java] 	at
[exec]      [java] 	at org.eclipse.equinox.launcher.Main.main(

Migration Guide

  • These changes should apply to anyone using PDE for builds & included JUnit tests.

Filename Explanation Before After
runtests switch from startup.jar to org.eclipse.equinox.launcher_*.jar cp="eclipse/startup.jar" cp=`find eclipse/ -name "org.eclipse.equinox.launcher_*.jar" | sort | head -1`
runtests switch Main classes org.eclipse.core.launcher.Main org.eclipse.equinox.launcher.Main
customTargets.xml (library.xml hack) add -nosplash flag -nosplash

Filename Explanation Before After don't pass -cp into runtests script to override value set there runtests -os linux -ws gtk -arch x86 -cp eclipse/startup.jar runtests -os linux -ws gtk -arch x86
runtests remove -noupdate flag (not supported anymore) org.eclipse.*.launcher.Main -noupdate org.eclipse.*.launcher.Main

Running Tests

To run tests, you'll need something like this:

$JAVA_HOME/bin/java $Xflags -enableassertions -cp $cp \
  org.eclipse.equinox.launcher.Main -ws $ws -os $os -arch $arch \
  -application org.eclipse.ant.core.antRunner -data $workspaceDir \
  -file test.xml $antTestTarget \
  $Dflags -Dws=$ws -Dos=$os -Darch=$arch -D$installmode=true $J2SE15flags \
  $properties -logger

The variables noted in the above example can be seen in detail in the runtests shell script.



Back to the top