“An unexpected error occured (return code -1)” when trying to launch SWTBot test suite with Tycho

走远了吗. 提交于 2019-12-08 11:52:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/25190212/an-unexpected-error-occured-return-code-1-when-trying-to-launch-swtbot-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!