title: TestNG: ClassCastException when returning Iterator in DataProvider in Eclipse
body: <p>In my TestNG test, I am using a DataProvider that returns an Iterator object, but when I run the test, I am getting an error. Could someone please explain why this is wrong and what I should do to fix it?</p>
  
  <p><strong>Eclipse Version:</strong></p>
  
  <pre><code>Eclipse Java EE IDE for Web Developers.
  
  Version: Oxygen.3a Release (4.7.3a)
  Build id: 20180405-1200
  </code></pre>
  
  <p><strong>Java Version</strong></p>
  
  <pre><code>java version "10.0.1" 2018-04-17
  Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
  Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
  </code></pre>
  
  <p><strong>Data Provider</strong></p>
  
  <pre><code>  @DataProvider(name = "SmokeTestData", parallel = true)
  public Iterator&lt;SmokeTestData&gt; smokeTestData(ITestContext context) {
      String fileName = context.getCurrentXmlTest().getParameter("filename");
      int numberOfTests = SmokeTestData.getNumberOfTests(fileName, true);
      SmokeTestData[] testSuiteData = new SmokeTestData[numberOfTests];
      for (int i = 1; i &lt;= numberOfTests; i++) {
          testSuiteData[i-1] = new SmokeTestData(fileName, i);
      }
      return (Stream.of(testSuiteData)).iterator();
  }
  </code></pre>
  
  <p><strong>Test</strong></p>
  
  <pre><code> @Test(description = "Smoke Test", dataProvider = "SmokeTestData", groups =
          {"SmokeTest"})
  @Description("Smoke Test")
  @Severity(SeverityLevel.NORMAL)
  public void smokeTest(SmokeTestData smokeTestData) {
      selectEnv(smokeTestData.getUrl());
      loginPage.get().smoketest(smokeTestData.getEnvironment(), smokeTestData.getEmail(), smokeTestData.getPassword());
      serviceAvailabilityPage.get().smoketest();
      referralRequestStatusPage.get().smoketest();
  }
  </code></pre>
  
  <p><strong>Data</strong></p>
  
  <pre><code>Environment,Url,Email,Password
  DE,https://somedomain.com/index.php/login,user@somedomain.com,somePW!1
  IN,https://somedomain.com/index.php/login,user@somedomain.com,somePW!1
  NM,https://somedomain.com/index.php/login,user@somedomain.com,somePW!1
  MI,https://somedomain.com/index.php/login,user@somedomain.com,somePW!1
  NV,https://somedomain.com/index.php/login,user@somedomain.com,somePW!1
  AK,https://somedomain.com/index.php/login,user@somedomain.com,somePW!1
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>java.lang.ClassCastException: data.SmokeTestData cannot be cast to java.base/[Ljava.lang.Object;
  at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1102)
  at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  at java.base/java.lang.Thread.run(Thread.java:844)
  </code></pre>
  
  <p>Thank you for any help in advance!!</p>