testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.98k stars 1.02k forks source link

DataProvider logic gets executed even when BeforeSuite method fails #1023

Closed monica-adriana closed 8 years ago

monica-adriana commented 8 years ago

In case the BeforeSuite method trows an exception, DataProvider logic still gets executed. I would expect DataProvider methods to be skipped, same as test methods.

juherr commented 8 years ago

By design, TestNG is creating tests then run tests.

To create tests, it uses DataProviders. Then it will run suites, tests, ...

You can try to define your data provider with Iterator<Object[]> as return type. It may work.

An Iterator<Object[]>. The only difference with Object[][] is that an Iterator lets you create your test data lazily. TestNG will invoke the iterator and then the test method with the parameters returned by this iterator one by one. This is particularly useful if you have a lot of parameter sets to pass to the method and you don't want to create all of them upfront.

http://testng.org/doc/documentation-main.html#parameters-dataproviders