1 package org.apache.maven.surefire.testng.utils;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.List;
23
24 import org.apache.maven.surefire.testset.TestListResolver;
25 import org.testng.IMethodSelector;
26 import org.testng.IMethodSelectorContext;
27 import org.testng.ITestNGMethod;
28
29
30
31
32
33
34
35
36 public class MethodSelector
37 implements IMethodSelector
38 {
39 private static volatile TestListResolver testListResolver = null;
40
41 public void setTestMethods( List arg0 )
42 {
43 }
44
45 public boolean includeMethod( IMethodSelectorContext context, ITestNGMethod testngMethod, boolean isTestMethod )
46 {
47 return testngMethod.isBeforeClassConfiguration() || testngMethod.isBeforeGroupsConfiguration()
48 || testngMethod.isBeforeMethodConfiguration() || testngMethod.isBeforeSuiteConfiguration()
49 || testngMethod.isBeforeTestConfiguration() || testngMethod.isAfterClassConfiguration()
50 || testngMethod.isAfterGroupsConfiguration() || testngMethod.isAfterMethodConfiguration()
51 || testngMethod.isAfterSuiteConfiguration() || testngMethod.isAfterTestConfiguration()
52 || shouldRun( testngMethod );
53 }
54
55 public static void setTestListResolver( TestListResolver testListResolver )
56 {
57 MethodSelector.testListResolver = testListResolver;
58 }
59
60 private static boolean shouldRun( ITestNGMethod test )
61 {
62 TestListResolver resolver = testListResolver;
63 boolean hasTestResolver = resolver != null && !resolver.isEmpty();
64 return hasTestResolver && resolver.shouldRun( test.getRealClass(), test.getMethodName() );
65 }
66 }