我使用的是rest-assured 4.4.0和Kotlin,这个简单的测试失败了:
Given {
body("hello")
}
When {
post("/endpoint/")
} Then {
statusCode(HttpStatus.SC_CREATED)
}rest-assured不会将body与请求一起发送:
Request method: POST
Request URI: http://localhost:52298/endpoint/
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Headers: Accept=*/*
Content-Type=application/json
Cookies: <none>
Multiparts: <none>
Body: <none>如果我切换到基于java的API,则测试通过:
given()
.body("hello")
.`when`()
.post("/endpoint")
.then()
.assertThat()
.statusCode(HttpStatus.SC_CREATED) 我在rest-assured github repo中找不到任何与这个问题相关的开放问题,我想知道我是不是做错了什么。
发布于 2021-10-20 17:08:16
格式错误,When块必须与Given块的右括号在同一行上。
错误的
Given {
body("{\"hello\":\"world\"}")
}
When {
...RIGHT
Given {
body("{\"hello\":\"world\"}")
} When {
...https://stackoverflow.com/questions/69643894
复制相似问题