复制Maven生成的测试报告

时间:2015-01-20 09:19:40

标签: java maven

我正在尝试将maven生成的测试运行报告复制到同一台计算机上的其他位置。我已经编写了代码来在拆解方法中复制报告,但目前问题是报告是在测试运行结束时由maven生成的,因此拆除方法无法找到报告。请让我知道应该在何处准确复制报告的代码

2 个答案:

答案 0 :(得分:0)

您可以配置Surefire报告插件以在其他位置生成报告:

<configuration>
  <outputDirectory>/some/absolute/path</outputDirectory>
</configuration>

有关详细信息,请参阅http://maven.apache.org/surefire/maven-surefire-report-plugin/examples/report-custom-location.html

如果您想在两个地方使用报告,最简单的解决方案可能是creating two executions两次运行报告插件。

答案 1 :(得分:0)

添加一个带有shell命令的插件来复制

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
   <execution>
      <id>copy_report</id>
      <phase>test</phase>
      <goals>
        <goal>exec</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <executable>/bin/cp</executable>
    <workingDirectory>${project.build.directory}/your/output/dir</workingDirectory>
    <arguments>
       <argument>your_report.txt</argument>
       <argument>/path/to/the/other/location</argument>
    </arguments>
  </configuration>
</plugin>
相关问题