0

I am wondering how to get the count of total number of test cases which are being executed in a testng suite for displaying it in testng customized report.As of now we are able to get the passed failed and skipped tests. Please enlighten.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
testergirl
  • 121
  • 1
  • 4
  • 11

1 Answers1

0

@Grasshoper's solutions sound good, just add them up, its quiet simple.

But if You using selenium/testng, try implementing methods by adding implements ITestListener to Your class and how have to implement this interface methods:

public interface ITestListener extends ITestNGListener {

  public void onTestStart(ITestResult result);

  public void onTestSuccess(ITestResult result);

  public void onTestFailure(ITestResult result);

  public void onTestSkipped(ITestResult result);

  public void onTestFailedButWithinSuccessPercentage(ITestResult result);

  public void onStart(ITestContext context);

  public void onFinish(ITestContext context);

and if You want to know exact number input code bellow to get all test methods:

public synchronized void onStart(ITestContext context) {
    TestRunner tRunner = (TestRunner) context;
    ITestNGMethod[] testMethods = tRunner.getAllTestMethods();
    int count = testMethods.length; 
}

Hope this helps...

Kovacic
  • 1,473
  • 6
  • 21