第谷跳过测试

时间:2016-05-04 00:05:17

标签: java maven junit tycho maven-surefire-plugin

我的项目使用maven进行构建,但在安装过程中它总是会跳过测试。如果我使用-X它告诉我:

[DEBUG]   (f) skipTests = true

这是从哪里来的?这是我的pom:

<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>
  <artifactId>project</artifactId>
  <packaging>eclipse-test-plugin</packaging>

  <parent>
    <groupId>project</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0</version>
  </parent>
      <dependencies>
         <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
         </dependency>
      </dependencies>  
  <build>
        <plugins>
      <plugin> 
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho-version}</version>
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
          <skipTests>false</skipTests>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

如果有任何日志或其他文件我可以提供帮助以找到原因,请告诉我。

1 个答案:

答案 0 :(得分:1)

1-使用tycho-surefire-plugin而不是maven-surefire-plugin。

2-您必须为测试定义target-platform-configuration。

3- all tycho-surefire-plugin参数可以找到here

示例:

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>tycho-surefire-plugin</artifactId>
    <version>${tycho.version}</version>
    <executions>
      <execution>
        <id>default-test</id>
        <phase>integration-test</phase>
        <goals>
          <goal>test</goal>
        </goals>
      </execution>
    </executions>
    <configuration> <!--example configuration run test in windows without GUI-->

      <argLine>-Xmx1024m</argLine> 
      <argLine>-Dosgi.arch=x86</argLine> 
      <useUIHarness>false</useUIHarness>
      <useUIThread>false</useUIThread>
    </configuration>
  </plugin>

目标平台的配置:

  <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho.version}</version>
            <configuration>
                <environments>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
                <dependency-resolution>
                    <optionalDependencies>ignore</optionalDependencies>
                    <extraRequirements>
                        <requirement>
                            <type>eclipse-plugin</type>
                            <id>org.eclipse.ui</id>
                            <versionRange>0.0.0</versionRange>
                        </requirement>
                        <requirement>
                            <type>eclipse-plugin</type>
                             <id>org.eclipse.ui.views</id>
                            <versionRange>0.0.0</versionRange>
                        </requirement>
                        <requirement>
                            .....
                        </requirement>
                    </extraRequirements>
                </dependency-resolution>
            </configuration>
        </plugin>

希望这会有所帮助。