01: package test.pkg;
02:
03: import org.testng.annotations.Test;
04:
05: import test.BaseTest;
06: import test.pkg2.Test2;
07:
08: import static org.testng.Assert.assertTrue;
09:
10: /**
11: * Tests that <package> in testng.xml works.
12: *
13: * Created on Aug 2, 2005
14: * @author cbeust
15: */
16: public class PackageTest extends BaseTest {
17: public static boolean NON_TEST_CONSTRUCTOR = false;
18:
19: @Test
20: public void stringSingle() {
21: addPackage("test.pkg2", new String[0], new String[0]);
22: run();
23: String[] passed = { "method11", "method12", "method31", };
24: String[] failed = {};
25: verifyTests("Passed", passed, getPassedTests());
26: verifyTests("Failed", failed, getFailedTests());
27: }
28:
29: @Test
30: public void packageWithNonTestClasses() {
31: addPackage("test.pkg2", new String[0], new String[0]);
32: run();
33: assertTrue(!NON_TEST_CONSTRUCTOR, Test2.class.getName()
34: + " should not be considered");
35: }
36:
37: @Test
38: public void packageWithRegExp1() {
39: addPackage("test.pkg2", new String[] { ".*1.*" }, new String[0]);
40: run();
41: String[] passed = { "method11", "method12", };
42: String[] failed = {};
43: verifyTests("Passed", passed, getPassedTests());
44: verifyTests("Failed", failed, getFailedTests());
45: }
46:
47: @Test
48: public void packageWithRegExp2() {
49: addPackage("test.pkg2", new String[0], new String[] { ".*1.*" });
50: run();
51: String[] passed = { "method31", };
52: String[] failed = {};
53: verifyTests("Passed", passed, getPassedTests());
54: verifyTests("Failed", failed, getFailedTests());
55: }
56:
57: @Test
58: public void packageWithRegExp3() {
59: addPackage("test.pkg2", new String[] { ".*3.*" },
60: new String[] { ".*1.*" });
61: run();
62: String[] passed = { "method31", };
63: String[] failed = {};
64: verifyTests("Passed", passed, getPassedTests());
65: verifyTests("Failed", failed, getFailedTests());
66: }
67:
68: @Test
69: public void packageWithRegExp4() {
70: addPackage("test.pkg2", new String[] { ".*1.*" },
71: new String[] { ".*3.*" });
72: run();
73: String[] passed = { "method11", "method12" };
74: String[] failed = {};
75: verifyTests("Passed", passed, getPassedTests());
76: verifyTests("Failed", failed, getFailedTests());
77: }
78:
79: @Test
80: public void packageWithRegExp5() {
81: addPackage("test.pkg2", new String[0],
82: new String[] { "Test.*" });
83: run();
84: String[] passed = {};
85: String[] failed = {};
86: verifyTests("Passed", passed, getPassedTests());
87: verifyTests("Failed", failed, getFailedTests());
88: }
89:
90: }
|