10
10
*/
11
11
public class TestNGListener implements IInvokedMethodListener2 {
12
12
13
+ private static final String BROWSER = "browser" ;
14
+ private static final String SELENIUM_URL = "seleniumUrl" ;
13
15
private String environment ;
14
16
private String browser ;
15
17
private String chrome ;
16
18
private String ie ;
17
19
private String firefox ;
18
20
private String safari ;
19
21
20
-
21
22
@ Override
22
23
public void beforeInvocation (IInvokedMethod method , ITestResult testResult , ITestContext context ) {
23
24
@@ -50,29 +51,29 @@ public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITes
50
51
}
51
52
52
53
if (method .isTestMethod () && annotationPresent (method , Url .class ) &&
53
- method . isTestMethod () && annotationPresent (method , Browser .class )) {
54
- System .setProperty ("seleniumUrl" , environment );
55
- System .setProperty ("browser" , browser );
54
+ annotationPresent (method , Browser .class )) {
55
+ System .setProperty (SELENIUM_URL , environment );
56
+ System .setProperty (BROWSER , browser );
56
57
} else if (method .isTestMethod () && annotationPresent (method , Url .class ) &&
57
- method . isTestMethod () && annotationPresent (method , Chrome .class )) {
58
- System .setProperty ("seleniumUrl" , environment );
59
- System .setProperty ("browser" , chrome );
58
+ annotationPresent (method , Chrome .class )) {
59
+ System .setProperty (SELENIUM_URL , environment );
60
+ System .setProperty (BROWSER , chrome );
60
61
} else if (method .isTestMethod () && annotationPresent (method , Url .class ) &&
61
- method . isTestMethod () && annotationPresent (method , Firefox .class )) {
62
- System .setProperty ("seleniumUrl" , environment );
63
- System .setProperty ("browser" , firefox );
62
+ annotationPresent (method , Firefox .class )) {
63
+ System .setProperty (SELENIUM_URL , environment );
64
+ System .setProperty (BROWSER , firefox );
64
65
} else if (method .isTestMethod () && annotationPresent (method , Url .class ) &&
65
- method . isTestMethod () && annotationPresent (method , Safari .class )) {
66
- System .setProperty ("seleniumUrl" , environment );
67
- System .setProperty ("browser" , safari );
66
+ annotationPresent (method , Safari .class )) {
67
+ System .setProperty (SELENIUM_URL , environment );
68
+ System .setProperty (BROWSER , safari );
68
69
} else if (method .isTestMethod () && annotationPresent (method , Url .class ) &&
69
- method . isTestMethod () && annotationPresent (method , InternetExplorer .class )) {
70
- System .setProperty ("seleniumUrl" , environment );
71
- System .setProperty ("browser" , ie );
70
+ annotationPresent (method , InternetExplorer .class )) {
71
+ System .setProperty (SELENIUM_URL , environment );
72
+ System .setProperty (BROWSER , ie );
72
73
} else if (method .isTestMethod () && annotationPresent (method , Url .class )) {
73
- System .setProperty ("seleniumUrl" , environment );
74
+ System .setProperty (SELENIUM_URL , environment );
74
75
} else if (method .isTestMethod () && annotationPresent (method , Browser .class )) {
75
- System .setProperty ("browser" , browser );
76
+ System .setProperty (BROWSER , browser );
76
77
}
77
78
}
78
79
@@ -91,7 +92,7 @@ public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
91
92
// TODO Auto-generated method stub
92
93
}
93
94
94
- private boolean annotationPresent (IInvokedMethod method , Class <? extends Annotation > clazz ) {
95
+ private static boolean annotationPresent (IInvokedMethod method , Class <? extends Annotation > clazz ) {
95
96
return method .getTestMethod ().getConstructorOrMethod ().getMethod ().isAnnotationPresent (clazz );
96
97
}
97
98
}
0 commit comments