当需要从 testng.xml 中的 2 个类运行测试时,为什么 TestNG 从类中随机选择方法?

发布于 2024-09-19 08:17:27 字数 387 浏览 3 评论 0原文

我需要使用 TestNG 运行 2 个类的测试。 testng.xml 配置指定:

<classes>
    <class name="com.xyz.TestA"></class>
    <class name="com.xyz.TestB"></class>
</classes>
  • TestA 具有方法: i1, i2, i3, i4
  • TestB 具有方法: j1, j2, j3, j4

测试按以下顺序运行:

i1, i3, j1, j4, i2, i4, j2,j3

有谁知道原因吗? 请各位帮忙~ 非常感谢!

I need to run tests from 2 classes with TestNG.
The testng.xml configuration specifies this:

<classes>
    <class name="com.xyz.TestA"></class>
    <class name="com.xyz.TestB"></class>
</classes>
  • TestA has methods: i1, i2, i3, i4
  • TestB has methods: j1, j2, j3, j4

The tests run in the following sequence:

i1, i3, j1, j4, i2, i4, j2, j3

Does anybody know the reason?
Pls kindly help~
Many thanks!

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

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

发布评论

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

评论(1

我喜欢麦丽素 2024-09-26 08:17:27

如果您使用的是最新的 TestNG,请使用“preserve-order”:

<test name="foo" preserve-order="true">
  <classes>
    <class...>

If you are using the latest TestNG, use "preserve-order":

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