如何使用TestNG并行运行属于特定组的测试用例

时间:2021-10-24 01:20:52

How to run test cases belonging to a particular group in parallel using TestNG. For example, let say there is a group named "up" containing 10 test cases. I want to run all these test cases in parallel (threads=number of test cases). How can I achieve in using TestNG.

如何使用TestNG并行运行属于特定组的测试用例。例如,假设有一个名为“up”的组包含10个测试用例。我想并行运行所有这些测试用例(线程=测试用例数)。如何使用TestNG实现。

1 个解决方案

#1


Try the following testng.xml. If you don't know the number of test cases before you run your code, just be sure that the threadCount is higher than it :)

尝试以下testng.xml。如果在运行代码之前不知道测试用例的数量,请确保threadCount高于它:)

  <suite parallel="methods" threadCount="10">    
    <test name="MyTest">
      <groups>
        <run>
          <include name="up"  />
        </run>
      </groups>

      <classes>
        <class name="test.TestClass" />
      </classes>
    </test>
  </suite>

#1


Try the following testng.xml. If you don't know the number of test cases before you run your code, just be sure that the threadCount is higher than it :)

尝试以下testng.xml。如果在运行代码之前不知道测试用例的数量,请确保threadCount高于它:)

  <suite parallel="methods" threadCount="10">    
    <test name="MyTest">
      <groups>
        <run>
          <include name="up"  />
        </run>
      </groups>

      <classes>
        <class name="test.TestClass" />
      </classes>
    </test>
  </suite>