Wrong arg count -parameterless test and conf method declaring Object[] #202

Closed
stumbav opened this Issue Apr 5, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@stumbav

stumbav commented Apr 5, 2012

In the scenario where a configuration method declares Objec[] type parameter and
is run for a parameterless test method, a superfluous (empty string) parameter is
added into the configuration method invocation, thus yielding IllegalArgumentException:

 @BeforeMethod setUp(@BeforeMethod setUp: 
    Wrong number of arguments were passed by the Data Provider: found 3 but expected 2)

Switching the configuration method parameters order didn't do the trick (similar issue - #128)

The following test clarifies the problem (run from Eclipse plugin: 6.4.0.20120308_1617 ):

@Test
public class TestNG_confMethodParamsBugTest {

    @BeforeMethod
    public void setUp(Object[] params, Method method) {}

    @Test(dataProvider="param")
    public void testMethod1_ok(String param) {}

    public void testMethod2_bug() {}

    @DataProvider(name="param")
    public Object[][] getParam() {
        return new Object[][]{{"Kuk"}};
    }
}   
@AlgoTheFun

This comment has been minimized.

Show comment Hide comment
@AlgoTheFun

AlgoTheFun Oct 21, 2013

This issue happened because you have a test method which does not get any parameters. I also faced the same issue and the issue was because of the JMockIt in the dependencies. JMockIt mocks the Parameters.getInjectedParameter and returns "" instead of null if test method does not get any parameters (https://code.google.com/p/jmockit/source/diff?spec=svn2378&r=2378&format=side&path=/trunk/main/src/mockit/integration/testng/internal/TestNGRunnerDecorator.java), because of the former reason TestNG returns 3 parameters instead of 2.
This issue was resolved in JMockIt-1.3 version (https://code.google.com/p/jmockit/issues/detail?id=297).
Hope this helps.

This issue happened because you have a test method which does not get any parameters. I also faced the same issue and the issue was because of the JMockIt in the dependencies. JMockIt mocks the Parameters.getInjectedParameter and returns "" instead of null if test method does not get any parameters (https://code.google.com/p/jmockit/source/diff?spec=svn2378&r=2378&format=side&path=/trunk/main/src/mockit/integration/testng/internal/TestNGRunnerDecorator.java), because of the former reason TestNG returns 3 parameters instead of 2.
This issue was resolved in JMockIt-1.3 version (https://code.google.com/p/jmockit/issues/detail?id=297).
Hope this helps.

@juherr

This comment has been minimized.

Show comment Hide comment
@juherr

juherr Jun 7, 2017

Collaborator

Closed because we are not able to reproduce it.
Check comments from #1445 by @krmahadevan

Collaborator

juherr commented Jun 7, 2017

Closed because we are not able to reproduce it.
Check comments from #1445 by @krmahadevan

@juherr juherr closed this Jun 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment