1 package test.methodselectors; 2 3 import org.testng.annotations.Test; 4 5 import test.BaseTest; 6 7 public class MethodSelectorTest extends BaseTest { 8 9 @Test negativePriorityAllGroups()10 public void negativePriorityAllGroups() { 11 addClass("test.methodselectors.SampleTest"); 12 addMethodSelector("test.methodselectors.AllTestsMethodSelector", -1); 13 run(); 14 String[] passed = { 15 "test1", "test2", "test3", 16 }; 17 String[] failed = { 18 }; 19 verifyTests("Passed", passed, getPassedTests()); 20 verifyTests("Failed", failed, getFailedTests()); 21 } 22 23 @Test negativePriorityGroup2()24 public void negativePriorityGroup2() { 25 addClass("test.methodselectors.SampleTest"); 26 addMethodSelector("test.methodselectors.Test2MethodSelector", -1); 27 run(); 28 String[] passed = { 29 "test2", 30 }; 31 String[] failed = { 32 }; 33 verifyTests("Passed", passed, getPassedTests()); 34 verifyTests("Failed", failed, getFailedTests()); 35 } 36 37 @Test lessThanPriorityTest1Test()38 public void lessThanPriorityTest1Test() { 39 addClass("test.methodselectors.SampleTest"); 40 addIncludedGroup("test1"); 41 addMethodSelector("test.methodselectors.Test2MethodSelector", 5); 42 run(); 43 String[] passed = { 44 "test1", "test2", 45 }; 46 String[] failed = { 47 }; 48 verifyTests("Passed", passed, getPassedTests()); 49 verifyTests("Failed", failed, getFailedTests()); 50 } 51 52 @Test greaterThanPriorityTest1Test2()53 public void greaterThanPriorityTest1Test2() { 54 addClass("test.methodselectors.SampleTest"); 55 addIncludedGroup("test1"); 56 addMethodSelector("test.methodselectors.Test2MethodSelector", 15); 57 run(); 58 String[] passed = { 59 "test2", 60 }; 61 String[] failed = { 62 }; 63 verifyTests("Passed", passed, getPassedTests()); 64 verifyTests("Failed", failed, getFailedTests()); 65 } 66 67 @Test lessThanPriorityAllTests()68 public void lessThanPriorityAllTests() { 69 addClass("test.methodselectors.SampleTest"); 70 addIncludedGroup("test1"); 71 addMethodSelector("test.methodselectors.AllTestsMethodSelector", 5); 72 run(); 73 String[] passed = { 74 "test1", "test2", "test3" 75 }; 76 String[] failed = { 77 }; 78 verifyTests("Passed", passed, getPassedTests()); 79 verifyTests("Failed", failed, getFailedTests()); 80 } 81 ppp(String s)82 public static void ppp(String s) { 83 System.out.println("[MethodSelectorTest] " + s); 84 } 85 } 86