Question

I´m running UI tests for an RCP application using SWTBot, which works fine while launching the tests in the eclipse IDE. Now I want to run the tests in maven, which also works so far. Unfortunately, through the dependency chain org.eclipse.swtbot.eclipse.finder --> org.eclipse.ui.editors --> org.eclipse.ui.ide the org.eclipse.ui.ide is also present in the application that runs the tests. With this bundle some unexpected menu items are present and the bundle should be excluded in the test runtime. How could this be achieved?

While running the tests in eclipse I simply exclude the org.eclipse.ui.ide bundle in the SWTBot Test launch configuration and everything works as expected.

Was it helpful?

Solution

The dependency chain org.eclipse.swtbot.eclipse.finder --> org.eclipse.ui.editors --> org.eclipse.ui.ide contains an optional link: the first bundle only requires the second bundle via an optional import of the package org.eclipse.ui.texteditor. This is why you can remove the o.e.ui.ide bundle from the test runtime launched from Eclipse, and o.e.swtbot.eclipse.finder will still work.

Under normal circumstances, you could achieve the same in Tycho's test runtime by making sure that the optional dependency is not in the target platform:

<plugin>
   <groupId>org.eclipse.tycho</groupId>
   <artifactId>target-platform-configuration</artifactId>
   <version>${tycho-version}</version>
   <configuration>
      <filters>
         <filter>
            <type>eclipse-plugin</type>
            <id>org.eclipse.ui.ide</id>
            <removeAll />
         </filter>
      </filters>
   </configuration>
</plugin>

But here is why this doesn't work in your particular case: When you use the UI test harness (useUIHarness=true), Tycho unconditionally adds the bundle org.eclipse.ui.ide.application as extra requirement to your test runtime. That bundle has a non-optional requirement to org.eclipse.ui.ide, so with the target platform configuration above, you'll get a "cannot resolve dependency" error complaining about an unsatisfied constraint of org.eclipse.ui.ide.application.

So, I don't think that there is a solution in your case – but I consider this a bug in Tycho. The SWT bot tests run in Eclipse, so they should also run in Tycho. Obviously, Eclipse doesn't need the org.eclipse.ui.ide.application bundle (or otherwise it would have stopped working when you de-selected the org.eclipse.ui.ide bundle), so Tycho shouldn't need it either. Please file a bug report for Tycho and attach a minimal sample project that reproduces the problem, so that I can fix this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top