I'm looking for a solution to execute failed test cases automatically on Jenkins. I'm currently running test cases through pom.xml which points to testng.xml

I'm using extent reports to capture and display test results which are located at this location on my workspace /ws/Resources/reports.html. Is there a way to just execute failed test cases based on extent report? and store the results in a new report.

I tried looking into testng-failed.xml solution but I don't think it actually captures the correct failed @Test methods, at least not in my case.

For every Test, I'm using extent report "Result.log(LogStatus.FAIL,"test case name")" in the catch block to mark a test case as failed so perhaps need something to read the test case name and execute it if it failed?

Any help would be greatly appreciated



you can execute using testng not extendreport. There will be a testng-failed.xml getting created at "test-output" folder you can use this to rerun code.

you can run scripts from java as :

    // Create object of TestNG Class
    TestNG testng = new TestNG();

    // Create a list of String
    List<String> suitefiles = new ArrayList<String>();

    // Add xml file which you have to execute

    // now set xml file for execution

    // finally execute the runner using run method

This will have all required listneres . You can also implement Iretryanazlyzer to rerun testng

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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