TestNg's group-by-instances not working as expected

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

TestNg's group-by-instances not working as expected

This post has NOT been accepted by the mailing list yet.
This post was updated on .
I am using TestNg 6.8.8, and have been trying to get tests to execute per instance, with little luck. Could someone please help me understand where I am going wrong. The following is my code.

<suite name="ExtendFactory" order-by-instances="true">
    <test name="Factory"  order-by-instances="true" preserve-order="false">
            <class name="com.test.SampleTest">


public class Sample {

    @DataProvider(name = "test1")
    public static Object[][] createData1() {
        return new Object[][] {
                { "Google" },
                { "Microsoft"},

    @DataProvider(name = "test2")
    public static Object[][] createData2() {
        return new Object[][] {
                { "Apple"},
                { "Yahoo"},

public class SampleTest {
    @Test(dataProvider = "test1",dataProviderClass = Sample.class)
    public void verifyData1(String n1) {

    @Test(dataProvider = "test2", dependsOnMethods="verifyData1",dataProviderClass = Sample.class)
    public void verifyData2(String n1) {

I want the result to be in this order : Google, Apple, Microsoft,Yahoo OR Apple,Yahoo,Google,Microsoft, but I get Google,Microsoft,Apple,Yahoo.

Note : I posted the same query in StackOverflow, but later realized that in the TestNg home site, the author himself responds! :-)