Skip to content

Commit 067ab3c

Browse files
authored
[java] Remove try/catch from tests
1 parent fcc549a commit 067ab3c

2 files changed

Lines changed: 12 additions & 20 deletions

File tree

java/test/com/thoughtworks/selenium/HttpCommandProcessorUnitTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717

1818
package com.thoughtworks.selenium;
1919

20-
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
21-
import static org.junit.jupiter.api.Assertions.assertEquals;
22-
import static org.junit.jupiter.api.Assertions.fail;
23-
import static org.mockito.Mockito.doReturn;
24-
import static org.mockito.Mockito.spy;
25-
2620
import org.junit.jupiter.api.Test;
2721

2822
import java.io.IOException;
@@ -33,6 +27,12 @@
3327
import java.net.HttpURLConnection;
3428
import java.net.URL;
3529

30+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
31+
import static org.junit.jupiter.api.Assertions.assertEquals;
32+
import static org.junit.jupiter.api.Assertions.fail;
33+
import static org.mockito.Mockito.doReturn;
34+
import static org.mockito.Mockito.spy;
35+
3636
/**
3737
* {@link com.thoughtworks.selenium.HttpCommandProcessor} unit test class.
3838
*/
@@ -102,15 +102,12 @@ public void testResourcesClosedWhenIoeOnGetInputStream() {
102102
}
103103

104104
@Test
105-
public void testResourcesClosedWhenNoIoes() {
105+
public void testResourcesClosedWhenNoIoes() throws IOException {
106106
IOEThrowingHttpCommandProcessor cmdProc = new IOEThrowingHttpCommandProcessor(
107107
"localhost", 4444, "*chrome", "http://www.google.com");
108-
try {
109-
cmdProc.getCommandResponseAsString("testCommand");
110-
cmdProc.verifyClosedResources(true, true, true);
111-
} catch (IOException ioe) {
112-
fail();
113-
}
108+
109+
cmdProc.getCommandResponseAsString("testCommand");
110+
cmdProc.verifyClosedResources(true, true, true);
114111
}
115112

116113
@Test

java/test/org/openqa/selenium/ExecutingJavascriptTest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import static java.util.Collections.singletonList;
4646
import static org.assertj.core.api.Assertions.assertThat;
4747
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
48-
import static org.junit.jupiter.api.Assertions.fail;
4948
import static org.junit.jupiter.api.Assumptions.assumeTrue;
5049
import static org.openqa.selenium.By.id;
5150
import static org.openqa.selenium.testing.drivers.Browser.CHROME;
@@ -491,16 +490,12 @@ public void testShouldThrowAnExceptionWhenArgumentsWithStaleElementPassed() {
491490

492491
@Test
493492
@Ignore(IE)
494-
public void testShouldBeAbleToReturnADateObject() {
493+
public void testShouldBeAbleToReturnADateObject() throws ParseException {
495494
driver.get(pages.simpleTestPage);
496495

497496
String date = (String) executeScript("return new Date();");
498497

499-
try {
500-
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(date);
501-
} catch (ParseException e) {
502-
fail();
503-
}
498+
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(date);
504499
}
505500

506501
@Test

0 commit comments

Comments
 (0)