Reputation: 151
How obtain the time taken for the method to be executed TESTNG?
Sample test:
@Test(threadPoolSize = 100, invocationCount = 100)
public void testA() throws Exception {
System.out.println("hello");
}
It will run 100 times. I want to obtain the time taken for the method testA for every execution.
Upvotes: 4
Views: 6722
Reputation: 5082
Usually this information is provided in TestNG report.
If you need this time while running test suite, in @AfterMethod use ITestResult object:
@AfterMethod
public void getRunTime(ITestResult tr) {
long time = tr.getEndMillis() - tr.getStartMillis();
}
Related: TestNG Dependency injection
Upvotes: 5