使用 maven-surefire-plugin 将测试报告发送到不同目录

发布于 2024-12-09 22:11:15 字数 2152 浏览 0 评论 0原文

我想生成报告,因此我使用了 maven-surefire-plugin

这是我的 pom.xml:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions> 
<execution> 
 <id>test-reports</id> 
    <phase>install</phase> 
    <configuration> 
      <tasks> 
<junitreport todir="./reports">
<fileset dir="./reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="./report/html"/>
</junitreport>
</tasks> 
    </configuration> 
    <goals> 
      <goal>test </goal> 
    </goals> 
  </execution> 
</executions> 
</plugin>

但是当我运行 Maven 测试时,我收到此错误:

 Tests run: 6, Failures: 2, Errors: 2, Skipped: 0
 [INFO] --------------------------------------------------------------------
 [INFO] BUILD FAILURE
 [INFO] --------------------------------------------------------------------
 [INFO] Total time: 10.403s
 [INFO] Finished at: Wed Oct 12 08:35:10 CEST 2011
 [INFO] Final Memory: 17M/126M
 [INFO] --------------------------------------------------------------------
 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-      plugin:2.10:test (default-test) on project jebouquine: There are test failures.
 [ERROR] 
 [ERROR] Please refer to C:\Users\Amira\workspace1\jebouquine\target\surefire-reports for the individual test results.
 [ERROR] -> [Help 1]
 [ERROR] 
 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
 [ERROR] 
 [ERROR] For more information about the errors and possible solutions, please read the following articles:
 [ERROR] [Help 1]       http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

当我打开 C:\Users\Amira\workspace1\jebouquine\target\surefire-reports 时,我找到了 repotrts,但我希望它们位于 下./报告

知道怎么做吗?或者有什么替代方法可以生成我的测试报告?

I want to generate my reports so I used maven-surefire-plugin.

This is my pom.xml:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions> 
<execution> 
 <id>test-reports</id> 
    <phase>install</phase> 
    <configuration> 
      <tasks> 
<junitreport todir="./reports">
<fileset dir="./reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="./report/html"/>
</junitreport>
</tasks> 
    </configuration> 
    <goals> 
      <goal>test </goal> 
    </goals> 
  </execution> 
</executions> 
</plugin>

But I'm getting this error when I run maven test:

 Tests run: 6, Failures: 2, Errors: 2, Skipped: 0
 [INFO] --------------------------------------------------------------------
 [INFO] BUILD FAILURE
 [INFO] --------------------------------------------------------------------
 [INFO] Total time: 10.403s
 [INFO] Finished at: Wed Oct 12 08:35:10 CEST 2011
 [INFO] Final Memory: 17M/126M
 [INFO] --------------------------------------------------------------------
 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-      plugin:2.10:test (default-test) on project jebouquine: There are test failures.
 [ERROR] 
 [ERROR] Please refer to C:\Users\Amira\workspace1\jebouquine\target\surefire-reports for the individual test results.
 [ERROR] -> [Help 1]
 [ERROR] 
 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
 [ERROR] 
 [ERROR] For more information about the errors and possible solutions, please read the following articles:
 [ERROR] [Help 1]       http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

When I open C:\Users\Amira\workspace1\jebouquine\target\surefire-reports I find repotrts but I want them under ./reports.

Any idea how to do it? Or is there any alternative to generate my tests reports?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯然 2024-12-16 22:11:15

看,这是底线:您需要阅读更多有关 Maven 的内容,因为您所写的内容没有意义。您尝试将 ant 配置元素填充到 Surefire 插件配置中,这根本不正确。并且您尝试将其绑定到安装阶段,但随后您正在运行mvn test

最后,如果您首先解释为什么希望它们位于不同的目录中,这可能会有所帮助......可能有更好的方法来实现您的真正目标。

不过,这将在接下来的 5 秒左右解决您的问题:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.10</version>
  <configuration>
    <reportsDirectory>${project.build.directory}/reports</reportsDirectory>
  </configuration> 
</plugin>

Look, here's the bottom line: you need to read more about Maven because what you have written does not make sense. You have tried to stuff ant configuration elements into the surefire plugin config, which is not right at all. And you have tried to bind it to the install phase, but then you are running mvn test.

Finally, it might help if you explained why you want them in a different directory in the first place ... there might be a better way to achieve your real goals.

However, this will fix your problem for the next 5 seconds or so:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.10</version>
  <configuration>
    <reportsDirectory>${project.build.directory}/reports</reportsDirectory>
  </configuration> 
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文