I have configured a Selenium TestNG project in Jenkins which contains 35 Test Cases. I'm not getting any emails when a test case fails in my Test Suite.

How can I configure Jenkins or my test suite need to get email when a test case fails?

  • 1
    any errors in the logs? What have you configured, what have you checked?
    – ECiurleo
    Jul 21, 2016 at 8:44
  • Have you confirmed that Jenkins can send emails at all?
    – corsiKa
    Jul 21, 2016 at 15:40
  • Did you add the e-mail to send notification field in project settings? What option did you select? Jul 27, 2016 at 11:05

2 Answers 2


This is effectively useful if we implement and use in scripts. #ValueAddition. There are multiple reasons why the test fails:

  1. Due to application downtime.
  2. Due to the network issue.
  3. Due to loading issue and etc.

But if the script is failing due to xpath and some valid reason then you have to maintain for re work on your scripts.

Solution -

package TestNGDemo;

import org.testng.IRetryAnalyzer;

import org.testng.ITestResult;

// implement IRetryAnalyzer interface

public class Retry implements IRetryAnalyzer{

      // set counter to 0

       int minretryCount=0;

      // set maxcounter value this will execute our test 3 times             

      int maxretryCount=2;

      // override retry Method

       public boolean retry(ITestResult result) {

            // this will run until max count completes if test pass within this frame it will come out of for loop


                   // print the test name for log purpose   

                     System.out.println("Following test is failing===="+result.getName());

                   // print the counter value    

                     System.out.println("Retrying the test Count is=== "+ (minretryCount+1));

                   // increment counter each time by 1  
                     return true;
              return false;

Hope it helps you !


You can use email-ext Jenkins plugin and create a post build step. With this you can set what the email contains (for example create an html body for the email, attach the results).

If you check the advanced options you can add triggers for what case it should send the email.

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.