如何使用我的RCP应用程序在Tycho SWTBot测试运行时添加插件 [英] How to add the plugin with my RCP application in the Tycho SWTBot test runtime

查看:164
本文介绍了如何使用我的RCP应用程序在Tycho SWTBot测试运行时添加插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的RCP是在3.x Eclipse上创建的,现在使用兼容性层在4.x上。
这是我的设置:我有两个插件: xyz-plugin xyz-rcp-plugin 。我的RCP应用程序由这两个插件组成。我有一个测试片段( xyz-test ),其主机插件是 xyz-plugin 并包含SWTBot测试。我的产品配置指向 xyz-rcp-plugin 的plugin.xml中定义的应用程序。

My RCP was created on a 3.x Eclipse and is now on 4.x using the compatibility layer. This is the setup that I have: I have two plugins: xyz-plugin and xyz-rcp-plugin. My RCP application is composed of these two plugins. I have a Test fragment (xyz-test) whose host plugin is xyz-plugin and contains SWTBot tests. My product configuration points to the application defined in the plugin.xml of xyz-rcp-plugin.

当我通过Eclipse运行SWTBot测试时,一切正常。我指向主选项卡上的正确应用程序,并启动正确的应用程序。

When I run the SWTBot Test via Eclipse, it all works ok. I point it to the correct application on the Main tab and it launches the correct one.

当我尝试通过Maven运行它(使用 mvn集成测试),在启动UI进行测试的命令之后,没有UI打开,只是报告说有测试失败,但是从来没有甚至达到测试我的情况的阶段。

When I try to run it via Maven (using mvn integration-test), after the command to launch the UI for testing, no UI opens and it just reports saying there are test failures but it never actually even reaches the stage for testing my cases.

我觉得这是发生的,因为我的测试片段只有 xyz-plugin 作为其主机,因此知道它的依赖关系,但是应用程序实际上包含在 xyz-rcp-plugin 中,所以我猜测它不会将该插件带入测试工作区。实际上,当我省略我的pom文件中的< application> 配置时,测试运行;它简单地启动了Eclipse SDK的默认值。

I feel this is happening because my test fragment only has xyz-plugin as its host and so knows its dependency but the application is actually contained in xyz-rcp-plugin so I am guessing it doesn't bring that plugin into the testing workspace. In fact, the test runs when I omit the <application> configuration in my pom file; it simple launches the default which is the Eclipse SDK.

所以,但是如果使用应用程序的插件不是依赖的,那么如何使SWTBot测试运行我的应用程序测试插件?

So but how can I make the SWTBot test run my application, if the plugin with the application is not a dependency of the test plugin?

以下是我的测试片段的pom文件,

Below is my pom file for the test fragment,

<?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>


推荐答案

Tycho不会自动添加定义配置< application> 到测试运行时 - 您需要手动确保包含此捆绑。

Tycho does not automatically add the bundle defining the configured <application> to the test runtime - you need to manually ensure that this bundle is included.

这样做是为了在测试项目的pom.xml中指定额外的依赖关系。这样,您可以将捆绑包或甚至整个功能(一如既往地包括传输依赖项)添加到测试运行时。

One way to do this is to specify extra dependencies in the pom.xml of the test project. In this way, you can add bundles or even entire features (as always, including transitive dependencies) to the test runtime.

示例pom.xml代码段:

Example pom.xml snippet:

<plugin>
  <groupId>org.eclipse.tycho</groupId>
  <artifactId>target-platform-configuration</artifactId>
  <version>${tycho-version}</version>
  <configuration>
    <dependency-resolution>
      <extraRequirements>
        <requirement>
          <type>eclipse-plugin</type>
          <id>xyz-rcp-plugin</id>
          <versionRange>0.0.0</versionRange>
        </requirement>
      </extraRequirements>
    </dependency-resolution>
  </configuration>
</plugin>

这篇关于如何使用我的RCP应用程序在Tycho SWTBot测试运行时添加插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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