Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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
Java Jenkins重复测试运行上的Cobertura_Java_Maven_Jenkins_Cobertura_Maven Cobertura Plugin - Fatal编程技术网

Java Jenkins重复测试运行上的Cobertura

Java Jenkins重复测试运行上的Cobertura,java,maven,jenkins,cobertura,maven-cobertura-plugin,Java,Maven,Jenkins,Cobertura,Maven Cobertura Plugin,我有一个包含cobertura的构建,作为我Jenkins跑步的一部分。然而,我现在意识到它正在运行我所有的测试两次 我将项目设置为Jenkins的Maven项目。我的目标是运行设置为:cleancoberture:cobertura安装 我原以为命令的install部分只会运行安装目标的其余部分,比如包。但是,它会重新运行编译和所有测试。这是尽管事实上已经有测试 我尝试过配置预构建和后构建步骤的不同组合,但我一直遇到问题。在某些组合中,构建工件(如JAR)永远不会在Jenkins上发布。在其他

我有一个包含cobertura的构建,作为我Jenkins跑步的一部分。然而,我现在意识到它正在运行我所有的测试两次

我将项目设置为Jenkins的Maven项目。我的目标是运行设置为:
cleancoberture:cobertura安装

我原以为命令的
install
部分只会运行安装目标的其余部分,比如包。但是,它会重新运行编译和所有测试。这是尽管事实上已经有测试

我尝试过配置预构建和后构建步骤的不同组合,但我一直遇到问题。在某些组合中,构建工件(如JAR)永远不会在Jenkins上发布。在其他情况下,测试结果丢失

我想也许我需要把这个构建重新制作成一个shell构建。我想我可以运行命令:
mvncleancobertura:cobertura&&mvnstall-Dmaven.test.skip=true

我想这会满足我的要求。它至少会停止运行所有测试两次

这是最好的方法还是有其他方法

这就是我在POM中加入Cobertura的方式:

  <?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.foo.bar</groupId>
    <artifactId>my-parent</artifactId>
    <version>1.2.1</version>
  </parent>

  <groupId>com.foo.bar.baz</groupId>
  <artifactId>osom</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <description>TODO</description>


  <modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
  </modules>

  <dependencies>
  </dependencies>

  <build>

    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>findbugs-maven-plugin</artifactId>
          <version>3.0.3</version>
        </plugin>
      </plugins>
    </pluginManagement>


    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18</version>
        <configuration>
          <useUnlimitedThreads>true</useUnlimitedThreads>
          <parallel>suites</parallel>
          <reuseForks>false</reuseForks>
          <includes>
            <include>**/*Test.java</include>
            <include>**/Test*.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <!-- use mvn cobertura:cobertura to generate cobertura reports -->
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          <aggregate>true</aggregate>
          <format>xml</format>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
</project>

4.0.0
com.foo.bar
我的父母
1.2.1
com.foo.bar.baz
奥索姆
0.0.1-快照
聚甲醛
待办事项
模块1
模2
模块3
org.codehaus.mojo
findbugs maven插件
3.0.3
org.apache.maven.plugins
maven编译器插件
1.7
1.7
org.apache.maven.plugins
maven jar插件
2.6
试验罐
org.apache.maven.plugins
maven surefire插件
2.18
真的
套房
假的
**/*Test.java
**/Test*.java
org.codehaus.mojo
cobertura maven插件
2.7
真的
xml

我能想到的最好办法是在詹金斯使用“自由式”项目

我让项目运行两个独立的maven命令。mvn clean cobertura:cobertura和mvn安装-Dmaven.test.skip=true


这可以防止测试运行两次。

我能想到的最佳方法是在Jenkins中使用“Freestyle”项目

我让项目运行两个独立的maven命令。mvn clean cobertura:cobertura和mvn安装-Dmaven.test.skip=true


这可以防止测试运行两次。

如果您不想运行两次测试,请使用maven插件而不是cobertura maven插件。

如果您不想运行两次测试,请使用maven插件而不是cobertura maven插件。

谢谢,我以后会检查的。谢谢,我以后会检查的。