1 package test.enable;
2 
3 import org.testng.TestNG;
4 import org.testng.annotations.Test;
5 
6 import test.SimpleBaseTest;
7 
8 import static org.assertj.core.api.Assertions.assertThat;
9 
10 public class EnableTest extends SimpleBaseTest {
11 
12   @Test
disabled_methods_should_not_be_run()13   public void disabled_methods_should_not_be_run() {
14     TestNG tng = create(A.class, B.class, C.class);
15     InvokedMethodListener listener = new InvokedMethodListener();
16     tng.addListener(listener);
17     tng.setPreserveOrder(true);
18     tng.run();
19 
20     assertThat(listener.getInvokedMethods()).containsExactly(
21         "beforeSuiteA", "beforeSuiteA2", "beforeSuiteNoRunA", "beforeSuiteNoRunA2", "beforeSuiteRunA", "beforeSuiteRunA2",
22         "beforeSuiteRunB", "beforeSuiteRunB2",
23         "beforeSuiteC", "beforeSuiteC2", "beforeSuiteNoRunC", "beforeSuiteNoRunC2", "beforeSuiteRunC", "beforeSuiteRunC2",
24         "testA2", "testA3", "testB2", "testB3", "testC", "testC2", "testC3",
25         "afterSuiteA", "afterSuiteA2", "afterSuiteNoRunA", "afterSuiteNoRunA2", "afterSuiteRunA", "afterSuiteRunA2",
26         "afterSuiteRunB", "afterSuiteRunB2",
27         "afterSuiteC", "afterSuiteC2", "afterSuiteNoRunC", "afterSuiteNoRunC2", "afterSuiteRunC", "afterSuiteRunC2"
28     );
29   }
30 
31   @Test(description = "https://github.com/cbeust/testng/issues/420")
issue420()32   public void issue420() {
33     TestNG tng = create(Issue420FirstSample.class, Issue420SecondSample.class);
34     InvokedMethodListener listener = new InvokedMethodListener();
35     tng.addListener(listener);
36     tng.run();
37 
38     assertThat(listener.getInvokedMethods()).containsExactly(
39         "alwaysBeforeSuite", "beforeSuite",
40         "verifySomethingFirstSample", "verifySomethingSecondSample",
41         "afterSuite", "alwaysAfterSuite"
42     );
43   }
44 }
45