문제

We use ratpack framework for building REST server and spock for testing.

I need to tune spock output when condition unsatisfied (eg. stacktrace or response dump)

For example, following test:

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
    }
}

Produces following error:

Condition not satisfied:

resp.statusCode() == 200
|    |            |
|    500          false
com.jayway.restassured.internal.RestAssuredResponseImpl@10b033e

How can I make spock to provide more details such as response body?

도움이 되었습니까?

해결책

I think you have to do something like:

assert resp.statusCode == 200,
       "resp.statusCode == $resp.statusCode (not 200) $resp.body"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top