How to get total amount of tests (incl. taking data providers into account) at TestNG start?

允我心安 提交于 2019-12-25 04:38:12

问题


Can anyone tell me how to get (expected) count of all tests / method executions at TestNG (suite) start?

You can easily get the amount of all test methods, but this doesn't count each test method times the amount of the data provider size (each method will be counted once, even if one method is executed 100 times via a data provider).

Unless there is an obvious solution to this, like a simple API call, the key seems to be to figure out the data provider method from the data provider name given in the @Test annotation, which I asked here: How to get data provider method from TestNG data provider name?

Once you know what the data provider method is, you could execute the data provider, and count the amount of data sets. This doesn't seem very efficient, but the tests we're running are not unit tests, so I wouldn't be too worried about executing the data providers twice (it will be a peanut compared to how long the actual tests run).


回答1:


You can use a listener and having your own count logic inside.



来源:https://stackoverflow.com/questions/31238604/how-to-get-total-amount-of-tests-incl-taking-data-providers-into-account-at-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!