作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 API 测试的新手,并试图弄清楚如何使用单个数组传递发布请求正文,该数组在放心的 API 测试中包含多组请求和属性。
{
"Transactions":
[
{"ReferenceId":"01","Id":"0727", "TCID": "67180405816294"},
{"ReferenceId":"02","Id":"0727", "TCID": "67180405816294"},
{"ReferenceId":"03","Id":"0727", "TCID": "67180405816294"}
]
}
最佳答案
听起来您想使用 restassured
将特定对象作为发布请求的正文进行发布。像下面这样的东西应该可以工作:
// If you are using Object Mapping (e.g. GSON or Jackson) create your test data as java objects
List<Reference> references = ...;
TransactionDTO data = new TransactionDTO(references);
// Else, not using mapping, so create test data as string:
String data = "{ \"Transactions\": [ ...]}";
given()
.contentType("application/json")
.body(data)
.queryParam("key", "value") //omit if not needed
when()
.post("/post/url/path")
then()
.<whatever assertions you need to make>
关于java - 安心API测试中如何传递数组post请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45443356/
我正在开发 Restful 服务,我们将在数据库中插入/更新新记录。 由于REST使用HTTP进行通信,而HTTP并不可靠,我担心如果连接失败,请求可能无法发送到服务器。 我在 link 中找到的建议
这是我对 GET 端点的restAssure 调用: public static Response getCall(int expectedStatusCode){ return given(
我是一名优秀的程序员,十分优秀!