SWTBot:使用tycho运行时出错

时间:2014-08-01 11:05:12

标签: junit eclipse-plugin eclipse-rcp swtbot tycho-surefire-plugin

我们正在为eclipse RCP应用程序编写SwtBot测试用例,它在eclipse中运行良好。现在我们将测试套件与现有的tycho集成在一起,这样在创建产品测试用例时也可以执行。为SWTBot测试套件创建的Pom.xml如下所述:

 <?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>
        <relativePath>../pom.xml</relativePath>

    </parent>
  <artifactId>com.tsystem.demo.client.gui.swtbot.test</artifactId>
  <version>6.0.0-SNAPSHOT</version>
    <packaging>eclipse-test-plugin</packaging>
  <name>demoEVO GUI :: USER SWTBOT</name>

  <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>
          <!-- use our product and application to launch 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>

我们还在父pom.xml中包含了SWTBot模块,它看起来如下所示:

    <?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <prerequisites>
        <maven>3.0</maven>
    </prerequisites>

    <groupId>com.test</groupId>
    <artifactId>com.test.demo.client.gui</artifactId>
    <version>6.0.0-SNAPSHOT</version>

    <packaging>pom</packaging>

    <name>demoEVO GUI :: PARENT</name>

    <modules>
        <module>com.test.demo.client.gui.ui</module>

        <module>com.test.demo.client.gui.feature</module>
        <module>com.test.demo.client.gui.product</module>
        <module>com.tsystem.demo.client.gui.swtbot.test</module>

    </modules>

    <repositories>
        <repository>
            <id>eclipse</id>
            <layout>p2</layout>
            <url>${eclipse-site}</url>
        </repository>
        <repository>
            <id>orbit</id>
            <layout>p2</layout>
            <url>${orbit-site}</url>
        </repository>
        <repository>
            <id>ajdt</id>
            <layout>p2</layout>
            <url>${ajdt-site}</url>
        </repository>
        <repository>
            <id>p2-babel</id>
            <layout>p2</layout>
            <url>http://download.eclipse.org/technology/babel/update-site/R0.11.1/indigo</url>
        </repository>
           <repository>
     <id>swtbot</id>
     <layout>p2</layout>
     <url>http://download.eclipse.org/technology/swtbot/releases/latest/</url>
   </repository>

    </repositories>

    <properties>
        <tycho-version>0.20.0</tycho-version>
        <platform-version-name>indigo</platform-version-name>
        <eclipse-site>http://download.eclipse.org/releases/${platform-version-name}</eclipse-site>
        <orbit-site>http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository</orbit-site>
        <ajdt-site>http://download.eclipse.org/tools/ajdt/37/update/</ajdt-site>
    </properties>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho-version}</version>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <pomDependencies>consider</pomDependencies>
                    <resolver>p2</resolver>
                    <environments>
                        <environment>
                            <os>win32</os>
                            <ws>win32</ws>
                            <arch>x86</arch>
                        </environment>
                    </environments>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-compiler-plugin</artifactId>
                    <version>${tycho-version}</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-p2-director-plugin</artifactId>
                    <version>${tycho-version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.4.1</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.3</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>com.test.demo.client.gui.framework.core</artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>
                com.test.demo.client.gui.automation.ui
            </artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>com.test.demo.client.gui.key.ui</artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>
                com.test.demo.client.gui.parameter.ui
            </artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>
                com.test.demo.client.gui.station.ui
            </artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>com.test.demo.client.gui.user.ui</artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>com.test.demo.client.gui.monitor.ui</artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
        <dependency>
            <groupId>com.test</groupId>
            <artifactId>
                com.test.demo.client.gui.transfer.ui
            </artifactId>
            <version>${project.version}</version>
            <type>eclipse-plugin</type>
        </dependency>
    </dependencies>

</project>

我们在tycho尝试执行SWTBot测试用例时遇到错误

[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 er
ror occured (return code -1). See log for details. -> [Help 1]

在日志文件中,它无法解析应用程序插件依赖项。这是日志文件的内容:

!SESSION 2014-08-01 16:21:02.349 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_45
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -application org.eclipse.tycho.surefire.osgibooter.uitest -testproperties D:\demo_EVO_PRODUCT_SWT\com.test.demo.client.gui\trunk\com.tsystem.demo.client.gui.swtbot.test\target\surefire.properties -testApplication com.test.demo.client.gui.ui.application -product com.test.demo.client.gui.ui.product -nouithread
Command-line arguments:  -data D:\demo_EVO_PRODUCT_SWT\com.test.demo.client.gui\trunk\com.tsystem.demo.client.gui.swtbot.test\target\work\data -application org.eclipse.tycho.surefire.osgibooter.uitest -testproperties D:\demo_EVO_PRODUCT_SWT\com.test.demo.client.gui\trunk\com.tsystem.demo.client.gui.swtbot.test\target\surefire.properties -testApplication com.test.demo.client.gui.ui.application -product com.test.demo.client.gui.ui.product -nouithread

!ENTRY org.eclipse.osgi 2 0 2014-08-01 16:21:03.564
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2014-08-01 16:21:03.564
!MESSAGE Bundle com.tsystem.demo.client.gui.swtbot.test_6.0.0.qualifier [1] was not resolved.
!SUBENTRY 2 com.tsystem.demo.client.gui.swtbot.test 2 0 2014-08-01 16:21:03.564
!MESSAGE Missing host com.test.demo.client.gui.ui_0.0.0.
!SUBENTRY 2 com.tsystem.demo.client.gui.swtbot.test 2 0 2014-08-01 16:21:03.564
!MESSAGE Missing required bundle com.test.demo.client.gui.framework.core_6.0.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2014-08-01 16:21:03.564
!MESSAGE Bundle com.test.demo.client.gui.ui_6.0.0.201408011050 [2] was not resolved.
!SUBENTRY 2 com.test.demo.client.gui.ui 2 0 2014-08-01 16:21:03.564
!MESSAGE Missing required bundle com.test.demo.client.gui.framework.core_6.0.0.
!SUBENTRY 1 org.eclipse.osgi 2 0 2014-08-01 16:21:03.564
!MESSAGE Bundle com.test.demo.client.gui.framework.core_6.0.0.201408010530 [6] was not resolved.
!SUBENTRY 2 com.test.demo.client.gui.framework.core 2 0 2014-08-01 16:21:03.564
!MESSAGE Missing Constraint: Bundle-RequiredExecutionEnvironment: JavaSE-1.7

请告诉我配置有什么问题?

1 个答案:

答案 0 :(得分:0)

您的产品是否是JUnit测试运行器?如果没有,则无法将其配置为tycho-surefire-plugin配置中的<product>。如果这样做,则没有测试运行器,因此不会执行任何测试。

如果要确保您的产品是测试运行时的一部分,则需要使用以下配置:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        <dependency-resolution>
            <extraRequirements>
                <requirement>
                    <type>p2-installable-unit</type>
                    <id>your-product-iu-id</id>
                    <versionRange>0.0.0</versionRange>
                </requirement>
            </extraRequirements>
        </dependency-resolution>
    </configuration>
</plugin>