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
package test;
 
import org.testng.Assert;
import org.testng.annotations.Configuration;
import org.testng.annotations.Test;
 
 
/**
 *
 * @author Cedric Beust, May 5, 2004
 *
 */
public class Test2 extends BaseTest {
  private boolean m_initializedCorrectly = false;
 
  @Configuration(beforeTestMethod = true)
//  @BeforeMethod
  public void correctSetup() {
    m_initializedCorrectly = true;
  }
 
  // Shouldn't be called
  @Configuration(beforeTestMethod = true, groups = "excludeThisGroup")
//  @BeforeMethod(groups = { "excludeThisGroup"} )
  public void incorrectSetup() {
    throw new RuntimeException("Should never be run");
  }
 
  @Test
  public void noGroups() {
    addClass("test.sample.Sample1");
    run();
    String[] passed = {
      "method1",
      "method2", "method3",
      "broken", "throwExpectedException1ShouldPass",
      "throwExpectedException2ShouldPass"
    };
    String[] failed = {
        "throwExceptionShouldFail", "verifyLastNameShouldFail"
    };
    verifyTests("Passed", passed, getPassedTests());
    verifyTests("Failed", failed, getFailedTests());
  }
 
  @Test
  public void setUpWithGroups() {
    run();
    Assert.assertTrue(m_initializedCorrectly, "Should have run the correctSetup method");
  }
 
  @Test
  public void partialGroupsClass() {
    addClass("test.sample.PartialGroupTest");
    addIncludedGroup("classGroup");
    run();
    String[] passed = {
        "testMethodGroup", "testClassGroup"
      };
      String[] failed = {
          "testMethodGroupShouldFail", "testClassGroupShouldFail"
      };
      verifyTests("Passed", passed, getPassedTests());
      verifyTests("Failed", failed, getFailedTests());
 
//      ppp("@@@@@@@@@@@@@@@@@@ PASSED TESTS");
//      for (Object o : getPassedTests().values()) {
//        ppp("@@@@@@@@@@ PASSED:" + o);
//      }
  }
 
  @Test
  public void partialGroupsMethod() {
    addClass("test.sample.PartialGroupTest");
    addIncludedGroup("methodGroup");
    run();
    String[] passed = {
        "testMethodGroup",
      };
      String[] failed = {
         "testMethodGroupShouldFail"
      };
      verifyTests("Passed", passed, getPassedTests());
      verifyTests("Failed", failed, getFailedTests());
  }
 
}