Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dataprovider in TestNg

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With reference to this interview of C�dric Beust

http://www.artima.com/lejava/articles/testng.html

I have question regarding dataProvider on whether we really need it ?

How is writing
different from

 
Cedric Beust
author
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Imagine that getData() returns a thousand different data sets. You want to have a thousand tests invoked, each with one set, not one test that tests one thousand different test cases...

--
Cedric


Originally posted by Pradip Bhat:
With reference to this interview of C�dric Beust

http://www.artima.com/lejava/articles/testng.html

I have question regarding dataProvider on whether we really need it ?

How is writing
different from

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cedric.Now I understand how dataprovider works. Sorry I did not read your interview completely.My fault. It is really useful feature.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like you said if there are 1000 records and 850th record cause the test to fail does, TestNg print the offending record or just would say that test fail ? Thanks
 
Cedric Beust
author
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradip,

Originally posted by Pradip Bhat:
Like you said if there are 1000 records and 850th record cause the test to fail does, TestNg print the offending record or just would say that test fail ? Thanks

The report tells you exactly which parameters were used for each invocation, so it's trivial to find out exactly which data set caused the test to fail.

--
Cedric
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Cedric Beust:
Hi Pradip,


The report tells you exactly which parameters were used for each invocation, so it's trivial to find out exactly which data set caused the test to fail.

--
Cedric


Thanks Cedric
 
Darvesh Niz
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extending on this topci of dataprovider, can i provide two dataprovider for one test method.
like for example i have oneDataprovider which provides queryString and i use that to get values from SOLR for different criteria.

then i have to sort of various datapoint like last name, firstname and i have to again provide a sort by criteria. hence i need to have one more dataprovider.

LEt me know
Thanks
 
Hermann Kuschke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cedric,

First of all, even though I'm sure many people have told what a great technology this is, I want to still thank you because it helps many coders out more than you can imagine.

My questions is related to dataprovider methods. In my case I am simply looking to test around 200 pages on a site on our intranet. Nothing complicated. Everything is working, but in the report the only thing that I am wondering about it why every single parameter is shown for each test.

Let me explain. My dataprovider method creates an Object[][] array for which each Object[] contains only an array of type String and length 1. The emailable report correctly reports that 200 tests were run and so on, but when I scroll down in the report, for each test (of 200) it shows all the parameters (all 200). So it doesn't just show the 1 parameter that relates to that instance of the test method, but instead it shows all the parameters every time.

I hope I have explained myself well enough. I am sure I am missing something. It is one of those cases where it feels like the technology should be able to display only the related parameter so for that reason I am fairly positive that I am doing something wrong.

Thanks in advance,

Hermann
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic