标签:ram str assert util red rom ror mcr .json
package Elaine.Test.G.APITest;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.restassured.response.Response;
import static io.restassured.RestAssured.*;
import static io.restassured.matcher.RestAssuredMatchers.*;
import static io.restassured.path.json.JsonPath.from;
import static org.hamcrest.Matchers.*;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.module.jsv.JsonSchemaValidator.*;
public class Get {
private Response response;
Map<String, Object> map = new HashMap<String, Object>();
int statuscode;
@BeforeTest
public void beforeTest() {
}
@Test
public void f() {
map.put("startDt", "2017-04-01");
map.put("enddt", "2019-05-24");
response = given().params(map).get("http://www.fakehost.com/api/v1/fakeurl");
statuscode = response.getStatusCode();
System.out.println(statuscode);
if(statuscode != 200){
throw new AssertionError("status code is" + statuscode + "by mistake");
}
//以下的code 是为了打印出来看所有的返回值的。不参与测试过程
String message = response.jsonPath().getString("Message");
System.out.println(message);
System.out.println(map);
map = null;
System.out.println(map);
}
}
标签:ram str assert util red rom ror mcr .json
原文地址:https://www.cnblogs.com/testertry/p/9903759.html