Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 18174c2

Browse files
committed
Merge pull request #5 from DevFactory/release/multiple-code-improvements-fix-1
multiple code improvements: squid:S1764, squid:S1192, squid:S2325
2 parents 0d86717 + b33049e commit 18174c2

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

‎src/main/java/org/sayem/webdriver/listeners/TestNGListener.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
*/
1111
public class TestNGListener implements IInvokedMethodListener2 {
1212

13+
private static final String BROWSER = "browser";
14+
private static final String SELENIUM_URL = "seleniumUrl";
1315
private String environment;
1416
private String browser;
1517
private String chrome;
1618
private String ie;
1719
private String firefox;
1820
private String safari;
1921

20-
2122
@Override
2223
public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITestContext context) {
2324

@@ -50,29 +51,29 @@ public void beforeInvocation(IInvokedMethod method, ITestResult testResult, ITes
5051
}
5152

5253
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);
5657
} 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);
6061
} 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);
6465
} 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);
6869
} 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);
7273
} else if (method.isTestMethod() && annotationPresent(method, Url.class)) {
73-
System.setProperty("seleniumUrl", environment);
74+
System.setProperty(SELENIUM_URL, environment);
7475
} else if (method.isTestMethod() && annotationPresent(method, Browser.class)) {
75-
System.setProperty("browser", browser);
76+
System.setProperty(BROWSER, browser);
7677
}
7778
}
7879

@@ -91,7 +92,7 @@ public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
9192
// TODO Auto-generated method stub
9293
}
9394

94-
private boolean annotationPresent(IInvokedMethod method, Class<? extends Annotation> clazz) {
95+
private staticboolean annotationPresent(IInvokedMethod method, Class<? extends Annotation> clazz) {
9596
return method.getTestMethod().getConstructorOrMethod().getMethod().isAnnotationPresent(clazz);
9697
}
9798
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /