01: package test.alwaysrun;
02:
03: import org.testng.Assert;
04: import org.testng.annotations.BeforeClass;
05: import org.testng.annotations.BeforeMethod;
06: import org.testng.annotations.BeforeSuite;
07: import org.testng.annotations.BeforeTest;
08: import org.testng.annotations.Test;
09:
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)
24: public void initSuite() {
25: m_beforeSuiteSuccess = true;
26: }
27:
28: @BeforeTest(alwaysRun=true)
29: public void initTest() {
30: m_beforeTestSuccess = true;
31: }
32:
33: @BeforeClass(alwaysRun=true)
34: public void initTestClass() {
35: m_beforeTestClassSuccess = true;
36: }
37:
38: @BeforeMethod(alwaysRun=true)
39: public void initTestMethod() {
40: m_beforeTestMethodSuccess = true;
41: }
42:
43: @Test(groups="A")
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:
51: public static boolean success() {
52: return m_beforeSuiteSuccess && m_beforeTestSuccess
53: && m_beforeTestClassSuccess
54: && m_beforeTestMethodSuccess;
55: }
56:
57: }
|