通过 Maven/Hudson 和 TestNG 使用多个类

发布于 2024-09-15 11:01:05 字数 414 浏览 1 评论 0原文

我们在一个 test 文件夹中使用多个测试类。当我运行 mvn test 时,所有测试都会运行,并且我可以在 shell 中看到输出。但生成的 testng-results.xml 仅包含其中测试的最后一个类的结果。这对我来说还不错,但我们的 Hudson 服务器仅显示这些最后的结果,并且仅在最后一类中的一个测试失败时才将构建标记为失败。

如何使用 TestNG 将测试分为多个类,并将这些类聚合到 results-xml 中?

[更新] 刚刚发现此问题,但也没有答案。 [/更新]

We use several testing classes within one test folder. When I run mvn test, all tests are run and I can see the output in the shell. But the resulting testng-results.xml only has the results of the last class which was tested in it. This isn't too bad for me, but our hudson server only displays these last results and only marks a build as failed if one test within that last class failed.

How can I use TestNG with tests split over several classes which will be aggregated into on results-xml?

[update]
Just found this question, but also no answer. [/update]

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

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

发布评论

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

评论(2

顾忌 2024-09-22 11:01:05

我不太确定 Hudson 发生了什么,但是您是否尝试过创建一个 testng.xml 文件并告诉 Surefire 使用该 testng.xml 文件,而不是仅仅发现与 Testjava 匹配的所有 Java 文件?

(只是在黑暗中拍摄)

你可以这样做:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <suiteXmlFiles>
        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
      </suiteXmlFiles>
    </configuration>
  </plugin>

I'm not quite sure what's going on with Hudson but have you tried creating a testng.xml file and telling Surefire to use that testng.xml file instead of just discovering all the Java files that match Testjava?

(just a shot in the dark)

This is how you do it:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <suiteXmlFiles>
        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
      </suiteXmlFiles>
    </configuration>
  </plugin>
素罗衫 2024-09-22 11:01:05

在一个 testNg 文件中的单独标签中执行单独的测试类并使用 maven-surefire 2.5 插件

execute separate test classses in separate tags in one testNg file and use maven-surefire 2.5 plugin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文