I'm writing some integration tests for my api. Now, i want to test an request that returns an 404. This is what i want, but groovy/hudson always marks my build as failed when i try it. This is, of course, because 404 is not between the accepted range.
I DO understand the error. The problem is that i don't know how to fix this.
Part of my Groovy file:
def testID = "fakeID"
response = httpRequest acceptType: "APPLICATION_JSON",
contentType: "APPLICATION_JSON",
customHeaders: [[name: 'Authorization', value: token]],
url: server+port+"/exams"+testID
Does anyone know how to make groovy accept this 404? All help beeing thanked for in advance!
You can use validResponseCodes
parameter to specify a range of valid response codes
response = httpRequest acceptType: "APPLICATION_JSON",
contentType: "APPLICATION_JSON",
customHeaders: [[name: 'Authorization', value: token]],
url: server+port+"/exams"+testID,
validResponseCodes: '200:404'
See httpRequest documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With