Skip to content

Instantly share code, notes, and snippets.

@amaralrfl
Last active July 29, 2018 02:15
Show Gist options
  • Save amaralrfl/37c1837dd997df9ab355eb9ab99b37c5 to your computer and use it in GitHub Desktop.
Save amaralrfl/37c1837dd997df9ab355eb9ab99b37c5 to your computer and use it in GitHub Desktop.
Class to configure and try run Rest Assured
import org.testng.annotations.Test;
import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static org.hamcrest.core.IsEqual.equalTo;
public class RestAssuredTest {
String url = "https://reqres.in/api/users";
@Test
public void getPageOne(){
given().
param("page", "1").
when().
get(url).
then().
statusCode(200).
body("page", equalTo(1));
}
@Test
public void getUser() {
get(url + "/2").then().body("data.id", equalTo(2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment