Search code examples
eclipsemaveneclipse-plugintychoeclipse-pde

Errors when executing tests in Tycho but not in Eclipse


I have a set of test cases that use the Eclipse WorkbenchPage and a couple of other classes to perform a set of functions.

When I execute the test bundle in Eclipse, all the test results are green. But when I "clean install" the same package in the command prompt, the build fails and shows test failures in my test classes.

What could be the problem here? I tried debugging my code from Maven but it didn't help at all.


Solution

  • Tycho and Eclipse differ in how they determine the test runtime:

    In Eclipse, by default the entire target platform and all projects from the workspace are included in the test runtime.

    In Tycho, only the test bundle/fragment and its transitive dependencies are part of the test runtime. If your test has implicit dependencies, e.g. on a bundle which provides some UI via an extension point, you need to explicitly configure these in Tycho.

    With the following build configuration, you can for example include the feature org.eclipse.rcp and all its transitive dependencies into the test runtime:

    <plugin>
       <groupId>org.eclipse.tycho</groupId>
       <artifactId>target-platform-configuration</artifactId>
       <version>${tycho-version}</version>
       <configuration>
          <dependency-resolution>
             <extraRequirements>
                <requirement>
                   <type>eclipse-feature</type>
                   <id>org.eclipse.rcp</id>
                   <versionRange>0.0.0</versionRange>
                </requirement>
             </extraRequirements>
          </dependency-resolution>
       </configuration>
    </plugin>