1.

There are failures in your suite execution, where only a few test cases have passed. How will you optimize your upcoming test runs in Selenium?

Answer»

In this case, re-running only the failed test cases would be an optimal solution. With the TestNG class, there are two methods to re-run only the failed test cases.


  • In the test output folder, the testng-failed.xml suite file is generated. We can use this to run only the previously failed test cases.

  • We can implement the TestNG IRetryAnalyzer interface. This can be done by creating a class ( say RetryAnalyzer) and implementing IRetryAnalyzer. Next, create a class ‘RetryListener’ by implementing an ‘IAnnotationTransformer’ interface, where the transform method is called for every test during the test run. Later, include the mentioned listeners in the testng.xml file.




Discussion

No Comment Found