如何获取执行TESTNG方法所需的时间

如何获取执行TESTNG方法所需的时间,testng,Testng,如何获得执行TESTNG方法所需的时间 样本测试: @Test(threadPoolSize = 100, invocationCount = 100) public void testA() throws Exception { System.out.println("hello"); } 它将运行100次。我想获得每次执行方法testA所花费的时间。通常,此信息在TestNG报告中提供 如果在运行测试套件时需要此时间,请在@AfterMethod use object中: 相关的

如何获得执行TESTNG方法所需的时间

样本测试:

@Test(threadPoolSize = 100, invocationCount = 100)
public void testA() throws Exception {
    System.out.println("hello");
}

它将运行100次。我想获得每次执行方法testA所花费的时间。

通常,此信息在TestNG报告中提供

如果在运行测试套件时需要此时间,请在@AfterMethod use object中:


相关的:

Long a=result.getEndMillis()-result.getStartMillis()使用这个方法,我现在可以得到时间了。谢谢你!是的,谢谢你指出。我打字太快了。我修正了答案。
@AfterMethod
public void getRunTime(ITestResult tr) {
    long time = tr.getEndMillis() - tr.getStartMillis();
}