001: package test;
002:
003: import java.util.ArrayList;
004: import java.util.List;
005: import java.util.logging.Handler;
006: import java.util.logging.Level;
007: import java.util.logging.Logger;
008:
009: public class Test1 extends BaseTest {
010: /**
011: * @testng.test groups="current"
012: */
013: public void includedGroups() {
014: addClass("test.sample.Sample1");
015: assert 1 == getTest().getXmlClasses().size();
016: addIncludedGroup("odd");
017: run();
018: String[] passed = { "method1", "method3" };
019: String[] failed = {};
020: verifyTests("Passed", passed, getPassedTests());
021: verifyTests("Failed", failed, getFailedTests());
022: }
023:
024: /**
025: * @testng.test
026: */
027: public void groupsOfGroupsSimple() {
028: addClass("test.sample.Sample1");
029: assert 1 == getTest().getXmlClasses().size();
030: // should match all methods belonging to group "odd" and "even"
031: addIncludedGroup("evenodd");
032: List l = new ArrayList();
033: l.add("even");
034: l.add("odd");
035: addMetaGroup("evenodd", l);
036: run();
037: String passed[] = { "method1", "method2", "method3", };
038: String[] failed = {};
039: verifyTests("Passed", passed, getPassedTests());
040: verifyTests("Failed", failed, getFailedTests());
041: }
042:
043: /**
044: * @testng.test
045: */
046: public void groupsOfGroupsWithIndirections() {
047: addClass("test.sample.Sample1");
048: addIncludedGroup("all");
049: List l = new ArrayList();
050: l.add("methods");
051: l.add("broken");
052: addMetaGroup("all", l);
053: l = new ArrayList();
054: l.add("odd");
055: l.add("even");
056: addMetaGroup("methods", l);
057: addMetaGroup("broken", "broken");
058: run();
059: String[] passed = { "method1", "method2", "method3", "broken" };
060: String[] failed = {};
061: verifyTests("Passed", passed, getPassedTests());
062: verifyTests("Failed", failed, getFailedTests());
063: }
064:
065: /**
066: * @testng.test
067: */
068: public void groupsOfGroupsWithCycle() {
069: addClass("test.sample.Sample1");
070: addIncludedGroup("all");
071: addMetaGroup("all", "all2");
072: addMetaGroup("all2", "methods");
073: addMetaGroup("methods", "all");
074: run();
075: String[] passed = {};
076: String[] failed = {};
077: verifyTests("Passed", passed, getPassedTests());
078: verifyTests("Failed", failed, getFailedTests());
079: }
080:
081: /**
082: * @testng.test
083: */
084: public void excludedGroups() {
085: addClass("test.sample.Sample1");
086: addExcludedGroup("odd");
087: run();
088: String passed[] = { "method2", "broken",
089: "throwExpectedException1ShouldPass",
090: "throwExpectedException2ShouldPass" };
091: String[] failed = { "throwExceptionShouldFail",
092: "verifyLastNameShouldFail" };
093: verifyTests("Passed", passed, getPassedTests());
094: verifyTests("Failed", failed, getFailedTests());
095: }
096:
097: /**
098: * @testng.test
099: */
100: public void regexp() {
101: addClass("test.sample.Sample1");
102: // should matches all methods belonging to group "odd"
103: addIncludedGroup("o.*");
104: run();
105: String passed[] = { "method1", "method3" };
106: String[] failed = {};
107: verifyTests("Passed", passed, getPassedTests());
108: verifyTests("Failed", failed, getFailedTests());
109: }
110:
111: /**
112: * @testng.test groups="currentold"
113: */
114: public void logger() {
115: Logger logger = Logger.getLogger("");
116: // System.out.println("# HANDLERS:" + logger.getHandlers().length);
117: Handler[] handlers = logger.getHandlers();
118: for (int i = 0; i < handlers.length; i++) {
119: handlers[i].setLevel(Level.WARNING);
120: handlers[i]
121: .setFormatter(new org.testng.log.TextFormatter());
122: }
123: logger.setLevel(Level.SEVERE);
124: }
125:
126: static private void ppp(String s) {
127: System.out.println("[Test1] " + s);
128: }
129:
130: } // Test1
|