01: package test;
02:
03: /**
04: *
05: * @author Cedric Beust, May 5, 2004
06: *
07: */
08: public class Test2 extends BaseTest {
09: private boolean m_initializedCorrectly = false;
10: private boolean m_initializedIncorrectly = false;
11:
12: /**
13: * @testng.before-method
14: */
15: public void correctSetup() {
16: m_initializedCorrectly = true;
17: }
18:
19: // Shouldn't be called
20: /**
21: * @testng.before-method groups="excludeThisGroup"
22: */
23: public void incorrectSetup() {
24: m_initializedIncorrectly = true;
25: }
26:
27: /**
28: * @testng.test
29: */
30: public void noGroups() {
31: addClass("test.sample.Sample1");
32: run();
33: String[] passed = { "method1", "method2", "method3", "broken",
34: "throwExpectedException1ShouldPass",
35: "throwExpectedException2ShouldPass" };
36: String[] failed = { "throwExceptionShouldFail",
37: "verifyLastNameShouldFail" };
38: verifyTests("Passed", passed, getPassedTests());
39: verifyTests("Failed", failed, getFailedTests());
40: }
41:
42: /**
43: * @testng.test
44: */
45: public void setUpWithGroups() {
46: run();
47: assert m_initializedCorrectly && (!m_initializedIncorrectly) : "Wrong set up method was called, correct:"
48: + m_initializedCorrectly
49: + " incorrect:"
50: + m_initializedIncorrectly;
51: }
52:
53: /**
54: * @testng.test
55: */
56: public void partialGroupsClass() {
57: addClass("test.sample.PartialGroupTest");
58: addIncludedGroup("classGroup");
59: run();
60: String[] passed = { "testMethodGroup", "testClassGroup" };
61: String[] failed = { "testMethodGroupShouldFail",
62: "testClassGroupShouldFail" };
63: verifyTests("Passed", passed, getPassedTests());
64: verifyTests("Failed", failed, getFailedTests());
65: }
66:
67: /**
68: * @testng.test
69: */
70: public void partialGroupsMethod() {
71: addClass("test.sample.PartialGroupTest");
72: addIncludedGroup("methodGroup");
73: run();
74: String[] passed = { "testMethodGroup", };
75: String[] failed = { "testMethodGroupShouldFail" };
76: verifyTests("Passed", passed, getPassedTests());
77: verifyTests("Failed", failed, getFailedTests());
78: }
79:
80: }
|