• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test;
2 
3 import org.testng.Assert;
4 import org.testng.annotations.Test;
5 
6 import test.sample.Sample2;
7 
8 public class MethodTest extends BaseTest {
9   private static final String CLASS_NAME = Sample2.class.getName();
10 
11   @Test(groups = { "current" })
includeMethodsOnly()12   public void includeMethodsOnly() {
13     addClass(CLASS_NAME);
14     Assert.assertEquals(getTest().getXmlClasses().size(), 1);
15     addIncludedMethod(CLASS_NAME, ".*method2");
16     run();
17     String[] passed = {
18       "method2",
19     };
20     String[] failed = {
21     };
22     verifyTests("Passed", passed, getPassedTests());
23     verifyTests("Failed", failed, getFailedTests());
24   }
25 
26   @Test(groups = { "current" })
excludeMethodsOnly()27   public void excludeMethodsOnly() {
28     addClass(CLASS_NAME);
29     Assert.assertEquals(getTest().getXmlClasses().size(), 1);
30     addExcludedMethod(CLASS_NAME, ".*method2");
31     run();
32     String[] passed = {
33       "method1", "method3"
34     };
35     String[] failed = {
36     };
37     verifyTests("Passed", passed, getPassedTests());
38     verifyTests("Failed", failed, getFailedTests());
39   }
40 
41   @Test
excludePackage()42   public void excludePackage() {
43     addClass(CLASS_NAME);
44     assert 1 == getTest().getXmlClasses().size();
45     addExcludedMethod(CLASS_NAME, ".*");
46     run();
47     String[] passed = {
48     };
49     String[] failed = {
50     };
51     verifyTests("Passed", passed, getPassedTests());
52     verifyTests("Failed", failed, getFailedTests());
53   }
54 }