Skip to content

Instantly share code, notes, and snippets.

@pluto-atom-4
Last active April 29, 2023 12:23
Show Gist options
  • Save pluto-atom-4/6316b4f524ebd9d9cd8a15a20878a881 to your computer and use it in GitHub Desktop.
Save pluto-atom-4/6316b4f524ebd9d9cd8a15a20878a881 to your computer and use it in GitHub Desktop.
Example Awaitility + AssertJ + Rest Assured
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"));
}
}
@bswjitsamal
Copy link

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment