How to implement SuccessPercentage in TestNG

Hi ,
I am a newbie in TestNG and learning the TestNG annotaions from toolsqa and but there isn’t any example explaining this parameter.

Can anyone explain with code the example of successpercentage? and

what is use of this in real world example?

Thanks! in advance 🙂

I am using the below code using success percentage as 100 but always it passes.I guess it shoud not pass because two iterates are failing here

package Pack;


import org.testng.annotations.Test;

public class SuccessPercentage {

@Test(timeOut = 10000, invocationCount = 1, successPercentage = 100)
public void waitForAnswer() throws InterruptedException{
int i=10;
while (i>2){

catch(Exception e)



Default Asked on June 21, 2015 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)


    because you have given invocation count as 1. it is trying only once.

    Change invocation count and check once. you have to give invocation count as 7 for your test to fail.

    Default Answered on January 25, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.