一.moco框架mock接口信息
[
{
"description": "这是一个能返回cookies信息的get请求",
"request": {
"uri": "/getCookies",
"method": "get"
},
"response": {
"cookies": {
"login": "true"
},
"text": "成功获取到cookies信息啦"
}
},
{
"description": "这是一个携带cookie和form-data数据的post请求",
"request": {
"uri": "/post/with/cookieform",
"method": "post",
"cookies": {
"login": "true"
},
"forms": {
"name": "lucy",
"age": "18"
}
},
"response": {
"status": 200,
"json": {
"status": "0",
"cookie": "success",
"lucy": "success"
}
}
}
]
二.application.properties配置文件信息
test.url=http://localhost:8080
getCookies.uri=/getCookies
test.get.with.cookies=/get/with/cookie
test.get.with.cookiesAndParams=/get/with/cookieparam
test.post.with.cookiesAndJsonData=/post/with/cookie
test.post.with.cookiesAndFormData=/post/with/cookieform
三.编写testNG测试方法
package com.course.httpclient.cookies;
import org.apache.http.HttpEntity;
import o