Question

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?

Was it helpful?

Solution

I think you have to do something like:

assert resp.statusCode == 200,
       "resp.statusCode == $resp.statusCode (not 200) $resp.body"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top