1 package test; 2 3 import org.testng.annotations.Test; 4 5 public class Exclude { 6 private boolean m_included1 = false; 7 private boolean m_included2 = false; 8 private boolean m_excluded1 = true; 9 private boolean m_excluded2 = true; 10 11 @Test(groups = { "group1"} ) included1()12 public void included1() { 13 ppp("INCLUDED1"); 14 m_included1 = true; 15 } 16 17 @Test(groups = { "group1"} ) included2()18 public void included2() { 19 ppp("INCLUDED2"); 20 m_included2 = true; 21 } 22 23 @Test(groups = { "group1"} ) excluded1()24 public void excluded1() { 25 ppp("EXCLUDED1"); 26 m_excluded1 = false; 27 } 28 29 @Test(groups = { "group1"} ) excluded2()30 public void excluded2() { 31 ppp("EXCLUDED1"); 32 m_excluded2 = false; 33 } 34 35 @Test(dependsOnGroups = { "group1" }, groups = {"group2"} ) verify()36 public void verify() { 37 ppp("VERIFY"); 38 assert m_included1 && m_included2 && m_excluded1 && m_excluded2: 39 "Should all be true: " + m_included1 + " " 40 + m_included2 + " " 41 + m_excluded1 + " " 42 + m_excluded2; 43 } 44 ppp(String s)45 static private void ppp(String s) { 46 if (false) { 47 System.out.println("[Exclude] " + s); 48 } 49 } 50 51 } 52