What determines the order in which dataProvider values are read?

17 views
Skip to first unread message

Eric Liu

unread,
Oct 28, 2019, 5:09:35 PM10/28/19
to testng-dev
In this simple example, the dataProvider is populated in this order: {"a", 1},{"b", 2},{"c", 3}
but is run in this order: 2,1,3.

dddd.PNG
























I would like to run the values through in the order in which they are added, so it would run with set 1,2,3. Thanks

Eric

unread,
Oct 29, 2019, 5:01:25 PM10/29/19
to testng-dev
You have no control over the order of the runs. It is not even guaranteed to run in the same order every time. Sometimes it could be 3,2,1 and next time it could be 1,2,3.
You only have limited control over the order of the methods.
If your tests are dependent on the order of the runs you need to separate them into different dataProviders and methods/classes. I suppose you could try to write an overly complicated and fragile listener to manipulate the order of execution by removing things from the test suite/run and adding them back one at a time after the last one has been executed.
Reply all
Reply to author
Forward
0 new messages