I'am running testng suite and then extent.html report is being generated. Now I want to customize my report like; i should be able to select only failed testcases in my report and then should be able to run them from there only and report should get updated. Any suggestions, how can i achieve this ?


4 Answers 4


Using TestNG's IretryAnalyzer interface's Retry method, you can re-run your failed test cases automatically.

But as far as I know, you can't update the already generated report.

But this should be understandable at your team/organization level as many times test fails not only because there is some defect, but due to internet connectivity loss or slowness or other many factors.

And on side note, try to use best practices as much as possible to automate your test cases so there would be very less or no flaky tests.

  • Thanks, i understand that but is there any way or any other report or some interactive customized way to achieve the same?
    – Anurvi Tak
    May 17, 2019 at 7:38
  • @AnurviTak As far as I know, there is no such report. You can do custom implementation but it would be a lot of effort and I would suggest to not put that much effort into it and put your effort elsewhere.
    – SRM21
    May 17, 2019 at 8:38

The Extent Report is just that, a report. You can't run tests using it, only see the results.

However, TestNG automatically creates a testng-failed.xml file after each run in the \test-output folder. This will be a pre-formatted XML that lists each item that failed in the last run, and will also auto include any custom parameters / etc that you might be using.

Using that you can run all those failed tests again after the run, the same way you run any other XML testNG file.

  • Thanks, i understand that but is there any way or any other report or some interactive customized way to achieve the same?
    – Anurvi Tak
    May 17, 2019 at 7:39
  • i've already done that which you have described, i've been asked to implement this. Any suggestions on it?
    – Anurvi Tak
    May 17, 2019 at 7:40
  • I'd be surprised if any report allows for that kind of thing. It sounds like what you're after is a build environment where people can fire off the tests, read the reports within the same environment and then afterwards fire off the resultant failed tests from that build. Have a look into Jenkins Server, this allows for that sort of thing.
    – Klynt
    May 17, 2019 at 7:53
  • Thanks. I'll check that.
    – Anurvi Tak
    May 17, 2019 at 7:56

To run only selected testcases from extent.html report in Selenium WebDriver, you can follow the steps below:

1 Create a custom testng.xml file where you can include only the testcases you want to run. You can use the testng.xml file to execute only the tests you specify.

2 Use the custom testng.xml file as a parameter when running the test suite. For example, you can use the following command to run only the testcases specified in your custom testng.xml file:

java -cp <path_to_testng.jar> org.testng.TestNG testng.xml

3 If you want to run only the failed testcases from the extent.html report, you can use the testng-failed.xml file. The testng-failed.xml file is generated automatically by TestNG and includes all the testcases that have failed in the previous run.

4 Use the testng-failed.xml file as a parameter when running the test suite. For example, you can use the following command to run only the failed testcases:

java -cp <path_to_testng.jar> org.testng.TestNG testng-failed.xml

5 To update the extent.html report with the results of the selected testcases, you can use the ExtentReports library, which integrates with TestNG. The ExtentReports library provides a way to generate detailed and interactive HTML reports for your test runs.

Note: The exact steps to run selected testcases and update the extent.html report may vary depending on your specific setup, so it's important to consult the documentation for your tools and libraries.


Step 1: Create a custom testng.xml file You'll want to selectively include only those test cases or test methods that you are interested in running. The testng.xml file provides a great deal of flexibility; you can include/exclude tests at the package, class, or method level.

<suite name="Suite">

Step 2: Use the custom testng.xml file as a parameter Running tests from the command line is particularly useful in continuous integration environments. Make sure you replace <path_to_testng.jar> with the actual path where the TestNG jar resides.

java -cp <path_to_testng.jar> org.testng.TestNG testng.xml

Step 3: Run only the failed test cases Once a test suite has been executed, TestNG will generate a testng-failed.xml file in the test output directory. This file contains information about all the test cases that failed during the last run. You can use this to rerun only the failed test cases, which is particularly useful in flaky test environments.

Step 4: Use the testng-failed.xml file as a parameter You can rerun just the failed tests by specifying testng-failed.xml as an argument, similar to how you ran the tests with the custom testng.xml file.

java -cp <path_to_testng.jar> org.testng.TestNG testng-failed.xml

Step 5: Update the extent.html report You can use the ExtentReports API to log the status of each test case. This will allow your extent.html report to be dynamically updated with the results of the selected tests. To make this happen, you typically would instantiate an ExtentReports object and use its methods in your test classes, possibly within TestNG annotations like @BeforeMethod, @AfterMethod

public class ExtentReportsTest {
ExtentReports extent;
ExtentTest test;

public void beforeMethod(Method method) {
    test = extent.createTest(method.getName());

public void afterMethod(ITestResult result) {
    if (result.getStatus() == ITestResult.FAILURE) {
    } else if (result.getStatus() == ITestResult.SUCCESS) {
        test.pass("Test passed");

} Note: Depending on your CI/CD setup or local development environment environment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.