[testng-dev] TestNG @DataProvider throws ClassCastException saying Cannot cast Student to Object

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[testng-dev] TestNG @DataProvider throws ClassCastException saying Cannot cast Student to Object

Vijay Sharma
ataProvider(name="mydp")
  public  Iterator<Student> newDataProvider()
  {
 Set <Student> s= new HashSet<Student>();
 s.add(new Student(1,"praveen"));
 return(s.iterator());
  }
  
  
  @Test (dataProvider = "mydp")
  public void testwithIterator( Student std) {
 
 System.out.println(std.name+ ", "+ std.number);
 
  }
}

 class Student
{
Integer number;
String name;
Student(Integer i, String s)
{
number=i;
name=s;
}
}

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: [testng-dev] TestNG @DataProvider throws ClassCastException saying Cannot cast Student to Object

Mark Derricutt
It helps if you actually ASK a question.

This should probably have been posted to the user list as well.

However - the data provider methods need to return Object[]'s, either an Object[][] or an Iterator<Object[]>. So rather than a set of your object, you need to have a set of object arrays, and put your object in that array.

On 26/06/2013, at 1:52 PM, Vijay Sharma <[hidden email]> wrote:

ataProvider(name="mydp")
  public  Iterator<Student> newDataProvider()


--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/groups/opt_out.