Order of methods execution when using "dependsOnGroups" in TestNG

22 views
Skip to first unread message

Jithin Mathew

unread,
Apr 10, 2017, 1:15:57 AM4/10/17
to testng-users
Hi All,

I want to do grouping mechanism between test classes effectively. So here is my test class structure.

Class A:

public class Group1 {

@Test(priority=1,groups = "A")

public void G1test1(){

    System.out.println("G1test1");


}

@Test(priority=2,groups = "A")

public void G1test2(){

System.out.println("G1test2");


}

}


Class B:


public class Group2 {

@Test(priority=1,groups = "B",dependsOnGroups="A")

public void G2test1(){

    System.out.println("G2test1");

  

}

@Test(priority=2,dependsOnGroups="A")

public void G2test2(){

System.out.println("G2test2");

}

}


Class C:


public class Group3 {

@Test(priority=1,groups = "B",dependsOnGroups="A")

public void G3test1(){

    System.out.println("G3test1");

}

@Test(priority=2,dependsOnGroups="A")

public void G3test2(){

System.out.println("G3test2");

}

}


Class D:

public class Group4 {

@Test(priority=1,groups = "C",dependsOnGroups="B")

public void G4test1(){

    System.out.println("G4test1");

   

}

@Test(priority=2,dependsOnGroups="B")

public void G4test2(){

    System.out.println("G4test2");

}

}



My testng xml file is like this,



<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Suite">

  <test name="Test1" preserve-order="true">

    <classes>

      <class name="grid.Group1"/>

      <class name="grid.Group2"/>

      <class name="grid.Group3"/>

      <class name="grid.Group4"/>

    </classes>

  </test> <!-- Test -->

</suite> <!-- Suite -->



Output:

G1test1

G1test2

G2test1

G3test1

G4test1

G2test2

G3test2

G4test2

Desired Output:


G1test1

G1test2

G2test1

G2test2

G3test1

G3test2

G4test1

G4test2


How can i achieve this?

Reply all
Reply to author
Forward
0 new messages