testng-team / testng

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

Data Provider clash with JMockit #600

Open chesshir opened 9 years ago

chesshir commented 9 years ago

JMockit allows you to have it mock up a class interface for only the scope of a single test function by making it a parameter to the test function that with the @Mocked attribute tagged onto it. JMockit injects a mock object for each parameter so marked. See http://jmockit.github.io/index.html for more details.

This feature will not work, however, when you are also trying to get TestNG to inject parameters through a Data Provider. The DataProvider thinks that you expect it to inject objects for ALL of the existing parameters, even though one or more of them is marked for JMockit to inject instead.

JMockit itself does not seem to offer any workaround. I tried getting JMockit to inject a parameter to the DataProvider, but it only will inject into a Test function. I tried making the test function attached to the Data Provider call another function with an extra parameter for JMockit to inject. (I passed null to the extra parameter and marked it in the called function with the @Mocked attribute.) Once again, JMockit would not inject the object since the called test function was not marked with the @Test attribute.

is there any way to get TestNG to recognize that it is not responsible for injecting every parameter on a test function?

cbeust commented 9 years ago

Not that I know.

juherr commented 8 years ago

@chesshir Is it working now. Can we close the issue?