Home | History | Annotate | Download | only in configuration
      1 package test.configuration;
      2 
      3 import org.testng.Assert;
      4 import org.testng.annotations.AfterGroups;
      5 import org.testng.annotations.Test;
      6 
      7 /**
      8  * afterGroups test when the group contains more than one method
      9  *
     10  * @author cbeust
     11  * @date Mar 7, 2006
     12  */
     13 public class ConfigurationGroups6SampleTest {
     14 
     15   private boolean m_after = false;
     16   private boolean m_run1 = false;
     17   private boolean m_run2 = false;
     18 
     19   @Test
     20   public void f() {
     21     log("f");
     22   }
     23 
     24   @Test(groups = "cg6-1")
     25   public void run1() {
     26     log("run1");
     27     Assert.assertFalse(m_after);
     28     m_run1 = true;
     29   }
     30 
     31   @Test(groups = "cg6-1")
     32   public void run2() {
     33     log("run2");
     34     Assert.assertFalse(m_after);
     35     m_run2 = true;
     36   }
     37 
     38   @AfterGroups("cg6-1")
     39   public void after() {
     40     log("after");
     41     Assert.assertTrue(m_run1);
     42     Assert.assertTrue(m_run2);
     43     Assert.assertFalse(m_after);
     44     m_after = true;
     45   }
     46 
     47   @Test(dependsOnGroups = { "cg6-1" })
     48   public void verify() {
     49     log("verify");
     50     Assert.assertTrue(m_run1, "run1() wasn't run");
     51     Assert.assertTrue(m_run2, "run2() wasn't run");
     52     Assert.assertTrue(m_after, "after1() wasn't run");
     53   }
     54 
     55   private void log(String string) {
     56     ppp(string);
     57   }
     58 
     59   private void ppp(String s) {
     60     if (false) {
     61       System.out.println("[ConfigurationGroups4SampleTest] " + s);
     62     }
     63   }
     64 
     65 }
     66