@Factory with dataProvider changes order of iterations
See original GitHub issueWhen a test class is instantiated by a constructor with @Factory annotation. Example:
public class TestTest {
int num;
@Factory(dataProvider = "data")
public TestTest(int n) {
num = n;
}
@DataProvider
public static Object [][] data() {
return new Object[][] {{1}, {2}, {3}, {4}};
}
@Test
public void test() {
System.out.println(num);
}
}
Expected output would be
1
2
3
4
but real order is different upon every execution. It appears that it essentially depends on test class instance hashcodes, where the list of nodes is sorted by default toString() implementation in org.testng.internal.Graph.java:129.
If dataprovider is specified in the @Test instead of @Factory, the order remains correct.
Issue Analytics
- State:
- Created 8 years ago
- Comments:20 (1 by maintainers)
Top Results From Across the Web
java - TestNG - Factories and Dataproviders - Stack Overflow
I'm working at a software firm developing a test automation framework to replace our old spaghetti tangled system. Since our system requires a ......
Read more >Changing test run sequence when using DataProvider
The idea here is to tie down factory to a data provider and then have the factory instantiate each of your test objects...
Read more >Different return types of DataProvider (TestNG - Part 35)
In this session, I have practically demonstrated Different return types of DataProvider in TestNG (i.e. Object[][], Object[], ...
Read more >How to Change a Test Name When Using TestNG DataProvider
You will only see the parameters that have been sent to the test function. But in case you implement a reporting mechanize, you...
Read more >version 1.3 - Spock Framework Reference Documentation
Let's try and change the second condition to stack.size() == 2 . ... If a data provider returns multiple values per iteration (as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Workarround: add
toString()
toTestTest
.The
Comparator
is onGraph.Node
and used duringGrapg#topologicalSort
.A comment says:
@JoaoGFarias I supposed we can remove it. Can you make a pull request with the toString removal?