简体   繁体   中英

Copying test report generated by Maven

I am trying to copy a test run report generated by maven to a different location on the same machine. I have written the code to copy the report in the teardown method but currently the problem is that the report is generated by maven at the end of the test run hence the tear down method is not able to find the report. Please let me know where exactly the code for copying the report should be written

You can configure the Surefire Report plugin to generate the report in a different place:

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

See http://maven.apache.org/surefire/maven-surefire-report-plugin/examples/report-custom-location.html for details.

If you want the report in both places, the most simple solution might be to run the report plugin twice by creating two executions .

Add a plugin with a shell command to copy

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM