本文介绍了当需要从 testng.xml 中的 2 个类运行测试时,为什么 TestNG 从类中随机选择方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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 有方法:i1、i2、i3、i4
  • TestB 有方法:j1、j2、j3、j4
  • 测试按以下顺序运行:

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

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

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

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

    推荐答案

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

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

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

    这篇关于当需要从 testng.xml 中的 2 个类运行测试时,为什么 TestNG 从类中随机选择方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 05:02