DataProvider with random data and RetryAnalyzer

299 views
Skip to first unread message

Graba

unread,
Oct 12, 2016, 9:23:50 AM10/12/16
to testng-users
Hi,

I have problem with random generated data in DataProvider along with RetryAnalyzer. I want to automatically retry failed tests with the same parameters like before, but it seems that each time the test is retried, different parameters are passed.
It seems like it is a bug.


@DataProvider(name = "data")
protected static Object[][] getData() {

Object[][] data = new Object[10][2];

for (int i = 0; i < 10; i++) {
for (int j = 0; j < 2; j++) {
data[i][j] = new Random().nextInt();
}
}

return data;
}


@Test(dataProvider = "data")
public void test(Integer rand1, Integer rand2) {
assertThat(false).isTrue();
}

Retry :

Graba

unread,
Oct 12, 2016, 9:30:16 AM10/12/16
to testng-users
Just for the record , I'm using TestNG 6.9.13.6


⇜Krishnan Mahadevan⇝

unread,
Oct 12, 2016, 11:43:03 PM10/12/16
to testng...@googlegroups.com
Graba,

AFAIK, TestNG would go back to invoking the data provider again to retrieve the data for the iteration that failed. Since your data provider is basically generating new data every time it is invoked via random generation, that is perhaps why you see your current behavior.

I don't think this is a bug in TestNG. You perhaps need to remove off the randomness in your data provider.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Wed, Oct 12, 2016 at 7:00 PM, Graba <grabagr...@gmail.com> wrote:
Just for the record , I'm using TestNG 6.9.13.6


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages