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上测试这个错误状态。