我们使用ratpack框架构建REST服务器,并使用spock进行测试。
当条件不满足时,我需要调整spock输出(例如堆叠或响应转储)
例如,以下测试:
def "Vk: Auth mr. John"() {
when:
request.param "vkId", vkId
request.param "vkToken", vkToken
request.port 5050
def resp = request.post "/auth/vk"
then:
resp.statusCode() == 200
def json = resp.jsonPath()
with(json) {
response != null
response.token != null
response.userId != null
}
}
产生以下错误:
Condition not satisfied:
resp.statusCode() == 200
| | |
| 500 false
com.jayway.restassured.internal.RestAssuredResponseImpl@10b033e
我如何使spock提供更多细节,如响应体?
I认为您必须执行以下操作:
assert resp.statusCode == 200,
"resp.statusCode == $resp.statusCode (not 200) $resp.body"