0

I am using a dataProvider method and forming a URL using this dataprovider and should pass this formed URL to next dataprovider . Can this dataprovider Test Method be ignored in the TestNG - test execution reports?

The first DataProvider A should be ignored in the TestNG - test execution report

@Test(dataprovider = "A")    
public void getURL(String URL){    
    finalURL = URL +apiURL;    
}

@Test(dataprovider ="B")    
public void getStatus(){    
    closeableHttpResponse = restClient.get(finalURL, headerFormation());     
}   
Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
rarunp04
  • 321
  • 2
  • 9
  • Would love to see a small screenshot in your question, showing the problem. – djangofan Jan 13 '19 at 19:05
  • please let me know if you need any specific details. The code which I am using is above . There are 2 tests - and I want to ignore one of the Test in reports – rarunp04 Jan 16 '19 at 07:05

1 Answers1

0

There is no out of the box way of doing this. A data driven test method is also a @Test method. TestNG doesn't distinguish them from a regular test method.

So the default reports within TestNG doesnot have this ability.

You can instead do the following:

  1. Make sure you are using TestNG 7.0.0-beta1 (latest released version as of today)
  2. Implement org.testng.IReporter (the reporting listener for testng).
  3. For every ITestResult object, just check if its a data driven method (You can do that by inspecting result.getMethod().isDataDriven() and checking if its true)
  4. If (3) is false you build a report for it and if (3) is true skip reporting the result for the test method.
Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66