lin
2025-08-01 633231e833e21d5b8b1c00cb15aedb62b3b78e8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package test;
 
import org.testng.annotations.Test;
 
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
 
public class Test1 extends BaseTest {
 
  /**
   * This constructor is package protected on purpose, to test that
   * TestNG can still instantiate the class.
   */
  Test1() {}
 
  @Test(groups = { "current" })
  public void includedGroups() {
    addClass("test.sample.Sample1");
    assert 1 == getTest().getXmlClasses().size();
    addIncludedGroup("odd");
    run();
    String[] passed = {
      "method1", "method3",
    };
    String[] failed = {
    };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test
  public void groupsOfGroupsSimple() {
    addClass("test.sample.Sample1");
    assert 1 == getTest().getXmlClasses().size();
    // should match all methods belonging to group "odd" and "even"
    addIncludedGroup("evenodd");
    List l = new ArrayList<>();
    l.add("even");
    l.add("odd");
    addMetaGroup("evenodd", l);
    run();
   String passed[] = {
    "method1", "method2", "method3",
   };
  String[] failed = {
  };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test
  public void groupsOfGroupsWithIndirections() {
    addClass("test.sample.Sample1");
    addIncludedGroup("all");
    List l = new ArrayList<>();
    l.add("methods");
    l.add("broken");
    addMetaGroup("all", l);
    l = new ArrayList<>();
    l.add("odd");
    l.add("even");
    addMetaGroup("methods", l);
    addMetaGroup("broken", "broken");
    run();
    String[] passed = {
      "method1", "method2", "method3", "broken"
    };
    String[] failed = {
    };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test
  public void groupsOfGroupsWithCycle() {
    addClass("test.sample.Sample1");
    addIncludedGroup("all");
    addMetaGroup("all", "all2");
    addMetaGroup("all2", "methods");
    addMetaGroup("methods", "all");
    run();
    String[] passed = {
    };
    String[] failed = {
    };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test // (groups = { "one" })
  public void excludedGroups() {
    addClass("test.sample.Sample1");
    addExcludedGroup("odd");
    run();
   String passed[] = {
    "method2",
    "broken", "throwExpectedException1ShouldPass",
    "throwExpectedException2ShouldPass"
   };
  String[] failed = {
      "throwExceptionShouldFail", "verifyLastNameShouldFail"
  };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test
  public void regexp() {
    addClass("test.sample.Sample1");
    // should matches all methods belonging to group "odd"
    addIncludedGroup("o.*");
    run();
   String passed[] = {
      "method1", "method3"
    };
    String[] failed = {
    };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test(groups = { "currentold" })
  public void logger() {
    Logger logger = Logger.getLogger("");
//    System.out.println("# HANDLERS:" + logger.getHandlers().length);
    for (Handler handler : logger.getHandlers())
    {
      handler.setLevel(Level.WARNING);
      handler.setFormatter(new org.testng.log.TextFormatter());
    }
    logger.setLevel(Level.SEVERE);
  }
 
  static public void ppp(String s) {
    System.out.println("[Test1] " + s);
  }
 
} // Test1