我正在使用Kotlin的放心4.4.0,这个简单的测试失败了:
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)
我找不到任何与此问题相关的github repo中的开放问题,我想知道我是否做错了什么。
格式错误,When
块必须与Given
块的右括号在同一行
错
Given {
body("{"hello":"world"}")
}
When {
...
对
Given {
body("{"hello":"world"}")
} When {
...