Does anyone know how TestNG figures out what the data provider method is based on the data provider name specified for a test method?
I found this solution: https://gist.github.com/ae6rt/3805639
However, it doesn't take into account that the data provider could be:
- defined in a completely different class, or
- defined in a parent class, and
- the method can be either static, or not static.
I tried to hack something together on my own, but then I figured that I can't possibly be the first person to try to solve the problem, especially because obviously TestNG must have a solution to that.
Does anyone know how TestNG does it, and how to get access to that business logic?
I'm trying to figure out the "total test count" at start up as discussed here: How to get total amount of tests (incl. taking data providers into account) at TestNG start?
This might be a very late answer, but still posting it.
The below samples show how it can be done using TestNG. I am using TestNG
7.0.0-beta1
(latest released version as of today).Scenario 1 : Data provider resides in the same class.
Scenario 2 : Data provider resides in a base class.
Scenario 3 : Data provider resides in a completely different class.
The listener which extracts all of this information and shows it to you