Last active
April 29, 2023 12:23
-
-
Save pluto-atom-4/6316b4f524ebd9d9cd8a15a20878a881 to your computer and use it in GitHub Desktop.
Example Awaitility + AssertJ + Rest Assured
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package internal.example.awaitility; | |
import org.awaitility.Awaitility; | |
import org.junit.Before; | |
import org.junit.Test; | |
import static io.restassured.RestAssured.get; | |
import static java.util.concurrent.TimeUnit.MILLISECONDS; | |
import static java.util.concurrent.TimeUnit.SECONDS; | |
import static org.assertj.core.api.Assertions.assertThat; | |
import static org.awaitility.Awaitility.await; | |
public class AwaitilityDSLTest { | |
@Before | |
public void setup() { | |
Awaitility.reset(); | |
Awaitility.setDefaultPollDelay(100, MILLISECONDS); | |
Awaitility.setDefaultPollInterval(3, SECONDS); | |
Awaitility.setDefaultTimeout(7, SECONDS); | |
} | |
@Test | |
public void testWithPollDelay() { | |
await().untilAsserted(() -> assertThat( | |
get("/foo.json") | |
.then() | |
.statusCode(200) | |
.extract().path("test").toString()).isEqualTo("hello0")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice