TestNG Tutorial #17 – How to Execute Failed Test Cases in Selenium

In this TestNG tutorial we will learn how to execute failed Test Cases in Selenium WebDriver. You can use TestNG retry analyzer to automatically retry a test whenever it fails.

Once you bind a retry analyzer to a test, TestNG automatically invokes the retry analyzer to determine if TestNG can retry a test case again in an attempt to see if the test that just failed now passes.

Following are the steps to use a retry analyzer:

✅ Step 1 – Build an implementation of the interface org.testng.IRetryAnalyzer

✅ Step 2 – Bind this implementation to the @Test annotation, example, @Test(retryAnalyzer = LocalRetry.class)

TestNG Tutorial #16 – How to Capture Screenshot for Failed Tests in TestNG

In this TestNG tutorial we will learn how to Capture Screenshot for Failed Tests in TestNG. TestNG provides @Listeners annotation to implement listeners in our test case and capture the screenshot on failure of any test case while test execution.

TestNG Tutorial #15 – What are TestNG Listeners

In this TestNG tutorial we will learn What are TestNG Listeners. TestNG provides @Listeners annotation to implement listeners in your test cases.

TestNG listeners listen to every event that occurs in the Selenium Test Case. Listeners modify the TestNG behavior which helps to redirect to new block of code based on certain events in your tests, for example, capture screenshot if test case failed.

TestNG Tutorial #14 – How to Pass Parameter from TestNG.xml File

In this TestNG tutorial we will learn How to Pass Parameter from TestNG.xml File. We will learn step by step how to define the parameters in the testng.xml file and then reference those parameters in your test case files.

TestNG Tutorial #13 – Move TestNG DataProvider into Different File

In this TestNG tutorial we will learn How to Move TestNG DataProvider into Different File. When you are referring to test data from TestNG DataProvider file, it is advised not to have data provider in each of your test case file.

When you externalize the data provider into separate file and refer the same file from all your test cases then your code become more maintainable. In this tutorial I will walk you through the process of moving the testng dataprovider into different file and referring it in your test cases.