【发布时间】:2014-11-17 17:18:26
【问题描述】:
我的 RCP 是在 3.x Eclipse 上创建的,现在使用兼容层在 4.x 上。
这是我的设置:我有两个插件:xyz-plugin 和 xyz-rcp-plugin。我的 RCP 应用程序由这两个插件组成。我有一个测试片段 (xyz-test),它的主机插件是 xyz-plugin 并包含 SWTBot 测试。我的产品配置指向xyz-rcp-plugin的plugin.xml中定义的应用。
当我通过 Eclipse 运行 SWTBot 测试时,一切正常。我将它指向主选项卡上的正确应用程序,它会启动正确的应用程序。
当我尝试通过 Maven(使用 mvn integration-test)运行它时,在启动 UI 进行测试的命令之后,没有 UI 打开,它只是报告说有测试失败,但实际上它甚至从未到达测试阶段我的案例。
我觉得这种情况正在发生,因为我的测试片段只有 xyz-plugin 作为它的主机,因此知道它的依赖关系,但应用程序实际上包含在 xyz-rcp-plugin 中,所以我猜它不会将该插件带入测试工作区.事实上,当我在 pom 文件中省略 <application> 配置时,测试就会运行;它会简单地启动默认的 Eclipse SDK。
但是,如果带有应用程序的插件不是测试插件的依赖项,我怎样才能让 SWTBot 测试运行我的应用程序?
下面是我的测试片段的 pom 文件,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.xyz</groupId>
<artifactId>all</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.xyz.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<properties>
<ui.test.vmargs></ui.test.vmargs>
</properties>
<profiles>
<profile>
<id>macosx</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<ui.test.vmargs>-XstartOnFirstThread</ui.test.vmargs>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useUIHarness>true</useUIHarness>
<useUIThread>false</useUIThread>
<product>com.xyz.rcp.product</product>
<application>com.xyz.rcp.Application</application>
<argLine>${ui.test.vmargs}</argLine>
<dependencies>
<dependency>
<!-- explicit dependency is only needed because SWTbot brings its
own hamcrest bundle which conflicts with the one from junit in the eclipse
platform -->
<type>p2-installable-unit</type>
<artifactId>org.hamcrest</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-xyz</id>
<phase>compile</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>true</excludeTransitive>
<includeTypes>tar.gz</includeTypes>
<outputDirectory>${project.build.directory}/work</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
当您以调试模式 (
-X) 运行构建时,Tycho 会告诉您哪些包在测试运行时中。 -
我试过了......但我仍然不确定在哪里添加我的 rcp 插件作为依赖项
标签: eclipse testing eclipse-rcp tycho swtbot