Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse 如何在Tycho SWTBot测试运行时添加带有我的RCP应用程序的插件_Eclipse_Testing_Eclipse Rcp_Tycho_Swtbot - Fatal编程技术网

Eclipse 如何在Tycho SWTBot测试运行时添加带有我的RCP应用程序的插件

Eclipse 如何在Tycho SWTBot测试运行时添加带有我的RCP应用程序的插件,eclipse,testing,eclipse-rcp,tycho,swtbot,Eclipse,Testing,Eclipse 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中定义的应用程序 当我通过Eclipse运行SWTBot测试时,一切正常。我将它指向主选项卡上的正确应用程序,它将启动正确的应用程序 当我尝试通过Ma

我的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文件中省略
配置时,测试就会运行;它简单地启动默认的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>

4.0.0
com.xyz
全部的
1.0.0-SNAPSHOT
com.xyz.test
eclipse测试插件
马科斯
雨衣
-XstartOnFirstThread
org.eclipse.tycho
第谷surefire插件
${tycho版本}
真的
假的
com.xyz.rcp.product
com.xyz.rcp.Application
${ui.test.vmargs}
p2可安装单元
org.hamcrest
0.0.0
org.apache.maven.plugins
maven依赖插件
解包xyz
编译
解包依赖项
真的
tar.gz
${project.build.directory}/work

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

一种方法是在测试项目的pom.xml中指定额外的依赖项。通过这种方式,您可以向测试运行时添加捆绑包甚至整个特性(一如既往,包括可传递的依赖项)

示例pom.xml代码段:

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

org.eclipse.tycho
目标平台配置
${tycho版本}
eclipse插件
xyzrcp插件
0.0.0

当您在调试模式(
-X
)下运行构建时,Tycho会告诉您哪些捆绑包在测试运行时。我尝试了。。。但是我仍然不确定在哪里添加我的rcp插件作为一个依赖相关的问题:你确实回答了我的问题。。。但这似乎没有帮助。它仍然默默地失败着……是的,我开始怀疑同样的事情。让我试试,我也会在这里更新帖子。谢谢你的帮助。我要投赞成票!我注意到,我在所有swt包上都遇到了一系列错误——缺少所需的功能Require capability:osgi.eeSo it worked!我必须在父pom文件中进行更改。。。我没有太多的maven经验,所以这可能是每个人都知道的,但是我必须改变我的模块顺序-所以我必须把我的rcp模块放在测试模块之前。也许你可以在你的答案上加上“别忘了”(除非这是非常基本的东西呵呵)谢谢!与此同时(自Tycho 0.21.0以来),通过在父POM中重新排序模块来手动更改构建顺序,不再对构建结果产生影响。相反,您需要使用答案中描述的配置来解决问题。