• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.alwaysrun;
2 
3 import org.testng.Assert;
4 import org.testng.annotations.BeforeClass;
5 import org.testng.annotations.BeforeMethod;
6 import org.testng.annotations.BeforeSuite;
7 import org.testng.annotations.BeforeTest;
8 import org.testng.annotations.Test;
9 
10 /**
11  * Tests alwaysRun on a before Configuration method.  Invoke this test
12  * by running group "A"
13  *
14  * @author cbeust
15  * @date Mar 11, 2006
16  */
17 public class AlwaysRunBefore1 {
18   private static boolean m_beforeSuiteSuccess = false;
19   private static boolean m_beforeTestSuccess = false;
20   private static boolean m_beforeTestClassSuccess = false;
21   private static boolean m_beforeTestMethodSuccess = false;
22 
23   @BeforeSuite(alwaysRun = true)
initSuite()24   public void initSuite() {
25     m_beforeSuiteSuccess = true;
26   }
27 
28   @BeforeTest(alwaysRun = true)
initTest()29   public void initTest() {
30     m_beforeTestSuccess = true;
31   }
32 
33   @BeforeClass(alwaysRun = true)
initTestClass()34   public void initTestClass() {
35     m_beforeTestClassSuccess = true;
36   }
37 
38   @BeforeMethod(alwaysRun = true)
initTestMethod()39   public void initTestMethod() {
40     m_beforeTestMethodSuccess = true;
41   }
42 
43   @Test(groups = "A")
foo()44   public void foo() {
45     Assert.assertTrue(m_beforeSuiteSuccess);
46     Assert.assertTrue(m_beforeTestSuccess);
47     Assert.assertTrue(m_beforeTestClassSuccess);
48     Assert.assertTrue(m_beforeTestMethodSuccess);
49   }
50 
success()51   public static boolean success() {
52     return m_beforeSuiteSuccess && m_beforeTestSuccess &&
53       m_beforeTestClassSuccess && m_beforeTestMethodSuccess;
54   }
55 
56 }
57