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