title: TestNG non static data provider method not working
body: <p>I have a test class and test method. This depends on data provider method. The data provider method is in different class other than the test class or one of its base classes. As per TestNG documentation</p>
  
  <blockquote>
    <p>If you want to put your data provider in a different class, it needs to be a static method or a class with a non-arg constructor, and you specify the class where it can be found in the dataProviderClass attribute</p>
  </blockquote>
  
  <p><strong>Test class:</strong></p>
  
  <pre><code>package test;
  
  import org.testng.Assert;
  import org.testng.annotations.Test;
  
  import dataprovider.TestDataProvider;
  
  public class TestClass {
        @Test(dataProvider = "get", dataProviderClass=TestDataProvider.class)
        public void test1(String s1, String s2) {
            Assert.assertEquals(s1.length(), s2.length());
        }
  }
  </code></pre>
  
  <p><strong>Data provider class:</strong></p>
  
  <pre><code>package dataprovider;
  
  import org.testng.annotations.DataProvider;
  
  public class TestDataProvider {
      @DataProvider(name = "get")
      public Object[][] testData() {
          return new Object[][] {{"a", "b"},{"c", "d"}};
      }
  }
  </code></pre>
  
  <p><strong>Test Output from Eclipse:</strong></p>
  
  <pre><code>    java.lang.RuntimeException: Can't invoke method public java.lang.Object[][] dataprovider.
  TestDataProvider.testData() on this instance of class test.TestClass due to class mismatch
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:75)
      at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:137)
      at org.testng.internal.Parameters.handleParameters(Parameters.java:430)
      at org.testng.internal.Invoker.handleParameters(Invoker.java:1243)
      at org.testng.internal.Invoker.createParameters(Invoker.java:992)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1082)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
      at org.testng.TestRunner.privateRun(TestRunner.java:778)
      at org.testng.TestRunner.run(TestRunner.java:632)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
      at org.testng.SuiteRunner.run(SuiteRunner.java:268)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1225)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1150)
      at org.testng.TestNG.runSuites(TestNG.java:1075)
      at org.testng.TestNG.run(TestNG.java:1047)
      at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
  </code></pre>
  
  <p>It seems it's not working. I am using TestNG 6.9.11 and tried running from maven as well as from eclipse. I am using latest Eclipse-TestNG plugin.</p>