API 테스트 코드 백업_스크립트 - shinyeoeun/My_Library GitHub Wiki
import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.path.json.JsonPath; import io.restassured.path.xml.XmlPath; import io.restassured.response.Response; import io.restassured.response.ResponseBody; import io.restassured.specification.RequestSpecification; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test;
import static io.restassured.RestAssured.*; import static org.hamcrest.Matchers.equalTo;
public class wow {
/* @BeforeClass static public void setup() { RestAssured.baseURI = "https://uat-ad.fsnsys.com"; // port = 80; } */
@Test
public void getAd() {
RestAssured
.given()
.params("code", "EcWTmRiT ")
.param("ad_form","banner")
.param("scode","F7F47876193C4876B350C5B23F669992")
.param("scode_type","idfa")
.param("idfa","F7F47876193C4876B350C5B23F669992")
.param("version","13.4.1")
.param("sdk_version","3.1.9")
.param("platform","iPhone")
.param("sdk_type","native")
.param("ad_count","1")
.param("content_type","json")
.when()
.get("https://uat-ad.fsnsys.com/caulyImpress")
.then()
.assertThat()
.body("response.title", equalTo("테스트"));
}
@Test
public void responseBody()
{
RestAssured.baseURI = "https://uat-ad.fsnsys.com";
RequestSpecification httpRequest = RestAssured.given();
Response response = httpRequest.get("/caulyImpress");
ResponseBody body = response.getBody();
System.out.println("Response Body is: " + body.asString());
}
@Test
public void checkCountryForFirstCar() {
RestAssured
.given()
.params("code", "yTnlAw5T ")
.param("ad_form","banner")
.param("scode","F7F47876193C4876B350C5B23F669992")
.param("scode_type","idfa")
.param("idfa","F7F47876193C4876B350C5B23F669992")
.param("version","13.4.1")
.param("sdk_version","3.1.9")
.param("platform","iPhone")
.param("sdk_type","native")
.param("ad_count","1")
.when()
.get("https://ad.cauly.co.kr/caulyImpress")
.then()
.assertThat()
.body("response", equalTo("테스트"));
}
}