"An unexpected error occured (return code -1)" when trying to launch SWTBot test suite with Tycho
Asked Answered
C

1

2

We are writing SWTBot tests for our Eclipse RCP application. Our RCP application includes NatTable components and has authorization mechanism to enable/disable perspectives. The test suite is working fine when launching it from Eclipse. Now we are trying to integrate it with Tycho.

This is the pom.xml created for running the SWTBot test suite:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.test</groupId>
    <artifactId>com.test.demo.client.gui</artifactId>
    <version>6.0.0-SNAPSHOT</version>
  </parent>
  <artifactId>com.tsystem.demo.client.gui.swtbot.test</artifactId>
  <packaging>eclipse-test-plugin</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-surefire-plugin</artifactId>
        <version>0.20.0</version>
        <configuration>
          <useUIHarness>true</useUIHarness>
          <useUIThread>false</useUIThread>
          <!-- launch our product and application in the tests -->
          <product>com.test.demo.client.gui.ui.product</product>
          <application>com.test.demo.client.gui.ui.application</application>
         </configuration>
      </plugin>
    </plugins>
  </build>
</project>

When we execute the Tycho build to launch the SWTBot test suite, we are getting below error:

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.20.0:test (default-test) on project com.tsystem.rvs.client.gui.swtbot.test: An unexpected error occured (return code -1). See log for details. -> [Help 1]

My first question is how Tycho can execute tests on our RCP application without first creating a product? I have tried few samples, and in those samples the test suite is executed before creating the product. We have custom configuration for splash screen, login mechanism to server, so is there additional configuration require to launch swtbot test suite. We have tried to launch RCP application with one perspective and view and it works fine with tycho but in our case tycho is not able to launch the application. There is no log file created under target/data and configuration as well.

Can someone explain from where Tycho takes the plugins to launch the application if the product is created after the execution of the SWTBot test suite?

Copperas answered 7/8, 2014 at 19:4 Comment(3)
Did you "see log for details" ?Strident
@Strident In this case there was in fact no relevant log output. This really should be improved: bugs.eclipse.org/bugs/show_bug.cgi?id=451580Guib
Related question: https://mcmap.net/q/1316352/-how-to-add-the-plugin-with-my-rcp-application-in-the-tycho-swtbot-test-runtime/1523648Guib
G
4

Can someone explain from where Tycho takes the plugins to launch the application if the product is created after the execution of the SWTBot test suite?

This is a good question, and it is getting close to the root cause of your problem.

But first we need to clarify the term "product". Unfortunately, it can mean two different things: A "product" can mean an extension to the org.eclipse.core.runtime.products extension point, or a product configuration file (*.product). For tests, only the product extension is relevant.

Similarly for applications, there is the extension point org.eclipse.core.runtime.applications.

So for your test to be able to use your product and application, the test runtime needs to contain the plug-ins that define the product and application extension. (Extension point extensions are defined in the plugin.xmls of plug-ins.) In Eclipse, this typically happens automatically because Eclipse includes all plug-ins from the workspace in the test runtime. It Tycho however - not having the concept of a workspace - the test runtime only contains the test plug-in and all its transitive dependencies. Your test plug-in doesn't seem to have a dependency on the plug-in defining product and application, so this is why the test execution fails. (BTW, /target/work/configuration/config.ini lists all plug-ins of the test runtime created by Tycho.)

So to add the plug-ins with the product and application extension to the test runtime, you can

  • add a dependency, e.g. Require-Bundle to them in the manifest of the test plug-in,
  • or configure extraRequirements of the test plug-in project as described here.

Some more details on the error message: The "return code -1" error is caused by configuring an <application> which is undefined in the test runtime.

Configuring an unknown <product> would not prevent the test to launch. In this case the only visible effect may be a "Product xxx.product.id could not be found" log entry in /target/work/data/.metadata/.log

P.S.: Since Tycho 0.22.0, there is a much more explicit error message if an application is configured that is undefined in the test runtime:

Could not find application "xyz" in test runtime. Make sure that the test runtime includes the bundle which defines this application.

Guib answered 14/11, 2014 at 15:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.