Static Import
Static import allows you to access the static member of a class directly without using the fully qualified name.
In order to use REST assured effectively it’s recommended to statically import methods from the following classes:
1 2 3 4 5 |
import static io.restassured.RestAssured.* import static io.restassured.matcher.RestAssuredMatchers.* import static org.hamcrest.Matchers.* import static io.restassured.module.jsv.JsonSchemaValidator.* |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
For example instead of doing: RestAssured.given() .param("x", "y") .when().get("/z") .then() .body("x.y", Matchers.equalTo("z")); We can write like this with static imports: given() .param("x", "y") .when().get("/z") .then() .body("x.y", equalTo("z")); |