ITestListener's methods get called multiple times | Selenium Forum
M
Posted on 24/11/2017
Hi,

When i run the Listener with TestNG 6.9 to 6.12 (webdriver 3 + ) the report out are saving for the single result multiple time

public void onTestSuccess(ITestResult tr){
report(tr.getName(), "PASS " + BaseTest.getNewData());

}


public void report(String name,String result){

try{
int iteration_number=1;
while(resultTable.containsKey(name+" Iteration "+iteration_number)){
iteration_number++;
}

keys.add(name+" Iteration "+iteration_number);
resultTable.put(name+" Iteration "+iteration_number, result);
}
catch(Exception e){
e.printStackTrace();
}
}



Result output

Test Case Result
Iteration 1 Skipping the test as runmode is N
Iteration 2 Skipping the test as runmode is N
Iteration 3 Skipping the test as runmode is N
Iteration 4 Skipping the test as runmode is N
Iteration 5 PASS 1546072
Iteration 6 PASS 1546072
Iteration 7 PASS 1546072
Iteration 8 PASS 1546072

M
Replied on 25/11/2017

no need to use ITestResult anymore. use extent reports.