import static io.restassured.RestAssured.*; import static org.hamcrest.Matchers.*; public class APITest { @Test public void testGetRequest() { given() .param("param1", "value1") .header("Authorization", "Bearer token") .when() .get("https://api.example.com/resource") .then() .statusCode(200) .body("data.id", equalTo(1)) .body("data.name", equalTo("John Doe")); } } @BeforeClass public static void setup() { RestAssured.baseURI = "https://api.example.com"; RestAssured.authentication = oauth2("token"); }


上一篇:
下一篇:
切换中文