|
2 | 2 |
|
3 | 3 | import static java.time.Duration.ofMillis;
|
4 | 4 | import static java.time.Duration.ofSeconds;
|
| 5 | +import static org.hamcrest.MatcherAssert.assertThat; |
5 | 6 | import static org.hamcrest.core.Is.is;
|
6 | 7 | import static org.hamcrest.core.StringContains.containsString;
|
7 |
| -import static org.junit.Assert.assertThat; |
8 |
| -import static org.junit.Assert.assertTrue; |
| 8 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 9 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
9 | 10 |
|
10 | 11 | import io.appium.java_client.functions.AppiumFunction;
|
11 | 12 | import io.appium.java_client.functions.ExpectedCondition;
|
12 |
| -import org.junit.Before; |
13 |
| -import org.junit.BeforeClass; |
14 |
| -import org.junit.Test; |
| 13 | +import org.junit.jupiter.api.BeforeAll; |
| 14 | +import org.junit.jupiter.api.BeforeEach; |
| 15 | +import org.junit.jupiter.api.Test; |
15 | 16 | import org.openqa.selenium.By;
|
16 | 17 | import org.openqa.selenium.TimeoutException;
|
17 | 18 | import org.openqa.selenium.WebDriver;
|
@@ -65,15 +66,15 @@ public class AndroidFunctionTest extends BaseAndroidTest {
|
65 | 66 | return null;
|
66 | 67 | };
|
67 | 68 |
|
68 |
| - @BeforeClass |
| 69 | + @BeforeAll |
69 | 70 | public static void startWebViewActivity() {
|
70 | 71 | if (driver != null) {
|
71 | 72 | Activity activity = new Activity("io.appium.android.apis", ".view.WebView1");
|
72 | 73 | driver.startActivity(activity);
|
73 | 74 | }
|
74 | 75 | }
|
75 | 76 |
|
76 |
| - @Before |
| 77 | + @BeforeEach |
77 | 78 | public void setUp() {
|
78 | 79 |
|
79 | 80 | driver.context("NATIVE_APP");
|
@@ -127,17 +128,19 @@ public void complexWaitingTestWithPreCondition() {
|
127 | 128 | assertThat("There should be 3 calls", calls.size(), is(3));
|
128 | 129 | }
|
129 | 130 |
|
130 |
| - @Test(expected = TimeoutException.class) |
| 131 | + @Test |
131 | 132 | public void nullPointerExceptionSafetyTestWithPrecondition() {
|
132 | 133 | Wait<Pattern> wait = new FluentWait<>(Pattern.compile("Fake_context"))
|
133 | 134 | .withTimeout(ofSeconds(30)).pollingEvery(ofMillis(500));
|
134 |
| - assertTrue(wait.until(searchingFunction.compose(contextFunction)).size() > 0); |
| 135 | + assertThrows(TimeoutException.class, |
| 136 | + () -> assertTrue(wait.until(searchingFunction.compose(contextFunction)).size() > 0)); |
135 | 137 | }
|
136 | 138 |
|
137 |
| - @Test(expected = TimeoutException.class) |
| 139 | + @Test |
138 | 140 | public void nullPointerExceptionSafetyTestWithPostConditions() {
|
139 | 141 | Wait<Pattern> wait = new FluentWait<>(Pattern.compile("Fake_context"))
|
140 | 142 | .withTimeout(ofSeconds(30)).pollingEvery(ofMillis(500));
|
141 |
| - assertTrue(wait.until(contextFunction.andThen(searchingFunction).andThen(filteringFunction)).size() > 0); |
| 143 | + assertThrows(TimeoutException.class, |
| 144 | + () -> assertTrue(wait.until(contextFunction.andThen(searchingFunction).andThen(filteringFunction)).size() > 0)); |
142 | 145 | }
|
143 | 146 | }
|
0 commit comments