Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

DataProvider wrong handling of Method and Array arguments to test methods #98

Open
GoogleCodeExporter opened this issue Apr 23, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

When using a Method and Array as argument to a test method, produced by a data 
provider method, the test does not run due to IllegalArgumentException.

seems very strange but does not allow me to use Helios...

here the test case which strangly fails:

import java.lang.reflect.Method;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;


public class TestTestNG {

    @Test(dataProvider="m")
    public void testMethod( Method m , Object[] args ) {

    }

    @DataProvider(name="m")
    public Object[][] getM() {
        Method m = getMethod();
        return new Object[][] {
            { m , new Object[] { "" } }
        };
    }

    private Method getMethod() {
        try {
            return Object.class.getMethod("toString");
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return null;
    }

}



Original issue reported on code.google.com by [email protected] on 21 Aug 2010 at 6:38

@GoogleCodeExporter
Copy link
Author

seen in TestNG 5.13.1

Original comment by [email protected] on 21 Aug 2010 at 6:42

@GoogleCodeExporter
Copy link
Author

Use @NoInjection:

@Test(dataProvider="m")
    public void testMethod(@NoInjection Method m , Object[] args ) {

Original comment by [email protected] on 21 Aug 2010 at 12:43

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant