Reputation: 35
I want to loop a test in testng in such a way that it records each loops execution time in test results. I have looped the test using Do-While but the testng records the entire time the loop took to finish the testcase. A simple view of my code is here.
class BackEndController{
@Test
public void fwdProcess(){
do{
//pick a pending request from a list
//perform some actions on it
//forward the request
}while(items are in the list)
}
}
Although it takes nearly a second for the loop to complete a cycle. But Testng records the entire time the fwdProcess takes (shows 3-4 minutes in result). So is there any annotation or a way that I can achieve the similar condtion by looping a test instead (until there are items in the list) so that I can get each execution time of the test?
Upvotes: 0
Views: 386
Reputation: 1609
If the loops are going to use the same data i think what you need is using invocationcount
@Test(invocationCount = 10)
public void testServer() {
}
This will invoke the same test 10 times and in the report you will get separate timings. You can set other parameters also with these like timeout, successPercentage etc.. Please read this for more information on these parameters and how they work
Upvotes: 0
Reputation: 5740
What you need is data provider:
class BackEndController {
@DataProvider
public Object[][] requests() {
// construct the array (or iterable) from a list
}
@Test(dataProvider = "requests")
public void fwdProcess(request) {
// perform some actions on the request
// forward the request
}
}
Upvotes: 0