RESTClient对象创建失败时检查错误状态?

时间:2017-06-20 02:46:53

标签: rest api spock

def client = new RESTClient("http://localhost:8080/myapp/api/v1/")
def "create account"() {
    when: "contentType is not specified"
    def resp = client.post(
            path: 'accounts/add',
            body: [
                name: "First Account",
                externalID: 300202302,
                active: true
            ]
            )

    then: "should throw an error"
    thrown(NullPointerException)
    resp.status == 415
}

问题是NullPointerException。当我在postman上尝试这个时,它将返回错误状态415.我想在spock上测试这个错误状态。

0 个答案:

没有答案