"An unexpected error occurred (return code -1)" when trying to run the SWTBot test package using Tycho

We are writing SWTBot tests for our RCP Eclipse application. Our RCP application includes NatTable components and has an authorization mechanism for enabling / disabling perspectives. The test suite works great when you run it from Eclipse. Now we are trying to integrate it with Tycho.

This is pom.xml created to run the SWTBot test package:

<?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 build Tycho to run the SWTBot test package, we get the following errors:

[ERROR] Failed to fulfill the goal org.eclipse.tycho: tycho-surefire-plugin: 0.20.0: test (default-test) in the project com.tsystem.rvs .client.gui.swtbot.test: An unexpected error occurred (code return -1). See the magazine for more details. β†’ [Help 1]

My first question is: how can Tycho run tests in our RCP application without first creating the product? I tried several samples, and in these samples a test suite is run before the product is created. We have a custom configuration for the splash screen, server login mechanism, so additional configuration is required to run the swtbot test suite. We tried to run the RCP application with one perspective and view, and it works fine with tycho, but in our case tycho cannot run the application. The log file created using the target / data and configuration is missing.

Can someone explain where Tycho gets the plugins to run the application if the product is created after the SWTBot test suite?

0
maven eclipse-rcp tycho tycho-surefire-plugin swtbot
source share
1 answer

Can someone explain where Tycho gets the plugins to run the application if the product is created after the SWTBot test suite?

This is a good question, and it is approaching the root cause of your problem.

But first, we need to clarify the term "product." Unfortunately, this can mean two different things: β€œProduct” can mean expanding to the extension point org.eclipse.core.runtime.products or the product configuration file ( *.product ). For tests, only product extension is important.

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

So, so that your test can use your product and application, the test runtime must contain plugins that determine the extension of the product and application. (Extensions of extension points are defined in plugin.xml plugins.) In Eclipse, this usually happens automatically, because Eclipse includes all plug-ins from the workspace in the test version. However, Tycho - without a working space concept - the test runtime contains only the test plugin and all its transitive dependencies. Your test plugin does not seem to depend on the plug-in defining the product and application, which is why this test is not executed. (BTW, /target/work/configuration/config.ini lists all the plugins in the test environment created by Tycho.)

So, to add plugins with the extension of the product and application to the test version, you can

  • add dependency for example. Require-Bundle to them in the manifest of the test plugin,
  • or configure the extraRequirements of the test plug-in project as described here .

Additional error information: The error "return code -1" is caused by the <application> setting, which is undefined in the test runtime.

Setting an unknown <product> will not prevent the test from starting. In this case, the only visible effect may be the "Product xxx.product.id could not be found" log /target/work/data/.metadata/.log

PS: Starting with Tycho 0.22.0, there is a much more explicit error message if the application is configured to undefined in the test runtime:

Could not find application "xyz" in test version. Make sure the test version includes the package that defines this application.

+1
source share

All Articles