001: package test.configuration;
002:
003: /**
004: * Test @Configuration
005: *
006: * @author cbeust
007: */
008: public class ConfigurationTest {
009: private boolean m_beforeSuite = false;
010: private boolean m_afterSuite = false;
011: private boolean m_beforeClass = false;
012: private boolean m_afterClass = false;
013: private boolean m_beforeMethod = false;
014: private boolean m_afterMethod = false;
015:
016: /**
017: * @testng.before-suite
018: */
019: public void beforeSuite() {
020: ppp("@@@@ BEFORE_SUITE");
021: assert !m_afterSuite : "afterSuite shouldn't have run";
022: assert !m_beforeClass : "beforeClass shouldn't have run";
023: assert !m_afterClass : "afterClass shouldn't have run";
024: assert !m_beforeMethod : "beforeMethod shouldn't have run";
025: assert !m_afterMethod : "afterMethod shouldn't have run";
026: m_beforeSuite = true;
027: }
028:
029: /**
030: * @testng.before-class
031: */
032: public void beforeClass() {
033: ppp("@@@@# BEFORE_CLASS");
034: assert m_beforeSuite : "beforeSuite should have run";
035: assert !m_afterSuite : "afterSuite shouldn't have run";
036: assert !m_beforeClass : "beforeClass shouldn't have run";
037: assert !m_afterClass : "afterClass shouldn't have run";
038: assert !m_beforeMethod : "beforeMethod shouldn't have run";
039: assert !m_afterMethod : "afterMethod shouldn't have run";
040: m_beforeClass = true;
041: }
042:
043: /**
044: * @testng.before-method
045: */
046: public void beforeMethod() {
047: ppp("@@@@ BEFORE_METHOD");
048: assert m_beforeSuite : "beforeSuite should have run";
049: assert m_beforeClass : "beforeClass have run";
050: assert !m_afterSuite : "afterSuite shouldn't have run";
051: assert !m_afterClass : "afterClass shouldn't have run";
052: assert !m_beforeMethod : "beforeMethod shouldn't have run";
053: assert !m_afterMethod : "afterMethod shouldn't have run";
054: m_beforeMethod = true;
055: }
056:
057: /**
058: * @testng.after-method
059: */
060: public void afterMethod() {
061: ppp("@@@@ AFTER_METHOD");
062: assert m_beforeSuite : "beforeSuite should have run";
063: assert m_beforeClass : "beforeClass have run";
064: assert m_beforeMethod : "beforeMethod should have run";
065: assert !m_afterSuite : "afterSuite shouldn't have run";
066: assert !m_afterClass : "afterClass shouldn't have run";
067: assert !m_afterMethod : "afterMethod shouldn't have run";
068: m_afterMethod = true;
069: }
070:
071: /**
072: * @testng.after-class
073: */
074: public void afterClass() {
075: ppp("@@@@ AFTER_CLASS");
076: assert m_beforeSuite : "beforeSuite should have run";
077: assert m_beforeClass : "beforeClass have run";
078: assert m_beforeMethod : "beforeMethod should have run";
079: assert m_afterMethod : "afterMethod should have run";
080: assert !m_afterClass : "afterClass shouldn't have run";
081: assert !m_afterSuite : "afterSuite shouldn't have run";
082: m_afterClass = true;
083: }
084:
085: /**
086: * @testng.after-suite
087: */
088: public void afterSuite() {
089: ppp("@@@@ AFTER_SUITE");
090: assert m_beforeSuite : "beforeSuite should have run";
091: assert m_beforeClass : "beforeClass have run";
092: assert m_beforeMethod : "beforeMethod should have run";
093: assert m_afterMethod : "afterMethod should have run";
094: assert m_afterClass : "afterClass should have run";
095: assert !m_afterSuite : "afterSuite shouldn't have run";
096: m_afterSuite = true;
097: }
098:
099: /**
100: * @testng.test
101: */
102: public void verify() {
103: ppp("@@@@ VERIFY");
104: assert m_beforeSuite : "beforeSuite should have run";
105: assert m_beforeClass : "beforeClass have run";
106: assert m_beforeMethod : "beforeMethod should have run";
107: assert !m_afterSuite : "afterSuite shouldn't have run";
108: assert !m_afterClass : "afterClass shouldn't have run";
109: assert !m_afterMethod : "afterMethod shouldn't have run";
110: }
111:
112: private static void ppp(String s) {
113: if (false) {
114: System.out.println("[ConfigurationTest] " + s);
115: }
116: }
117:
118: }
|