“发生意外错误(返回代码-1)".尝试使用Tycho启动SWTBot测试套件时 [英] "An unexpected error occured (return code -1)" when trying to launch SWTBot test suite with Tycho

查看:116
本文介绍了“发生意外错误(返回代码-1)".尝试使用Tycho启动SWTBot测试套件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为Eclipse RCP应用程序编写SWTBot测试.我们的RCP应用程序包括NatTable组件,并具有用于启用/禁用透视图的授权机制.从Eclipse启动测试套件时,它运行良好.现在,我们正在尝试将其与Tycho集成.

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.

这是为运行SWTBot测试套件而创建的pom.xml:

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>

当我们执行Tycho构建以启动SWTBot测试套件时,我们得到以下错误:

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

[错误]无法在项目com.tsystem.rvs.client.gui.swtbot.test上执行目标org.eclipse.tycho:tycho-surefire-plugin:0.20.0:test(默认测试)发生错误(返回代码-1).有关详细信息,请参见日志. -> [帮助1]

[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]

我的第一个问题是,在没有先创建产品的情况下,第谷如何才能在我们的RCP应用程序上执行测试?我尝试了一些示例,在这些示例中,测试套件是在创建产品之前执行的.我们为启动屏幕,服务器登录机制提供了自定义配置,因此启动swtbot测试套件是否需要其他配置.我们试图用一个透视图和视图启动RCP应用程序,并且它与tycho一起正常工作,但是在我们的情况下tycho无法启动该应用程序.在目标/数据和配置下也没有创建日志文件.

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.

如果产品是在执行SWTBot测试套件后创建的,那么有人可以解释Tycho从哪里带插件来启动应用程序?

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?

推荐答案

如果产品是在执行SWTBot测试套件后创建的,那么有人可以解释Tycho从哪里带插件来启动应用程序?

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.

但是首先我们需要弄清楚产品"一词.不幸的是,这可能意味着两件事:产品"可以表示对org.eclipse.core.runtime.products扩展点的扩展,或者是产品配置文件(*.product).对于测试,仅产品扩展名是相关的.

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.

类似地,对于应用程序,有扩展点org.eclipse.core.runtime.applications.

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

因此,为了使您的测试能够使用您的产品和应用程序,测试运行时需要包含定义产品和应用程序扩展的插件. (扩展点扩展是在插件的plugin.xml中定义的.)在Eclipse中,这通常是自动发生的,因为Eclipse在测试运行时中包含了工作空间中的所有插件.但是,它是Tycho(没有工作区的概念),测试运行时仅包含测试插件及其所有传递依赖项.您的测试插件似乎并不依赖于定义产品和应用程序的插件,因此这就是测试执行失败的原因. (顺便说一句,/target/work/configuration/config.ini列出了由Tycho创建的测试运行时的所有插件.)

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

  • 添加依赖项,例如在测试插件清单中对他们Require-Bundle
  • 或按照此处.
  • 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.

有关错误消息的更多详细信息:返回代码-1"错误是由配置在测试运行时中未定义的<application>引起的.

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.

配置未知的<product>不会阻止测试启动.在这种情况下,唯一可见的效果可能是/target/work/data/.metadata/.log

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.::自Tycho 0.22.0起,如果配置了在测试运行时中未定义的应用程序,则会出现更明显的错误消息:

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:

在测试运行时找不到应用程序"xyz".确保测试运行时包含定义此应用程序的捆绑软件.

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

这篇关于“发生意外错误(返回代码-1)".尝试使用Tycho启动SWTBot测试套件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆