如何在循环中多次 运行 多个测试方法

How can I run multiple test methods multiple times in a loop

public class OrionTripCreation extends GeneratePayload {
    
    String route_set_id = null;
    String warehouse_name = null;
    String transaction_id = null;
    String lr_number = null; 
    String bid_id = null;
    String message = null;
    String transaction_status = null;
    String trip_status = null;
    String payment_Id = null;
    String oracle_id = null;
    String intermittent_payment_id = null;
    String intermittent_oracle_id = null;
        
    OrionUtility orion = new OrionUtility();

     @Test(invocationCount = 10)
    
      public void generateLR() throws Exception { 
         lr_number =orion.generateLRNumber();
          ExtentTestManager.getTest().log(LogStatus.INFO,"LR Number is generated :-" + lr_number);    
      }
     
     @Test 
      public void raiseIndent() throws Exception { 
          transaction_id =orion.raiseIndent(); 
          ExtentTestManager.getTest().log(LogStatus.INFO,"Indent is created :-" + transaction_id);
          trip_status = orion.fetchStatusForTransaction("requested" , transaction_id);
      
      }
...
}

我尝试使用 @Test(invocationCount = n),但它 运行 多次只使用该方法,我想 运行 所有方法一次,然后 运行 测试第二次时间

这是TestNG题,我会用一个简单的例子来说明。

  • 测试class
package demo;

import org.testng.annotations.Test;

public class MultipleTest {

    @Test
    public void testName() {
        System.out.println("tess 1");
    }

    @Test
    public void testName2() {
        System.out.println("tess 2");
    }
}
  • 测试套件xml:src/test/resources/testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
    <test name="exampletest1">
        <classes>
            <class name="demo.MultipleTest" />
        </classes>
    </test>
</suite>
  • 运行 来自 main 方法的 TestNG 文件:
public class AppDemo {

    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            List<String> suites = List.of("src/test/resources/testng.xml");
            TestNG tng = new TestNG();
            tng.setTestSuites(suites);
            tng.run();
        }
    }
}

它将运行所有测试3次。