Neb*_*sar 3 apache groovy http-headers jenkins
我正在为我的api编写一些集成测试.现在,我想测试一个返回404的请求.这就是我想要的,但groovy/hudson总是在我尝试时将我的构建标记为失败.当然,这是因为404不在可接受的范围之间.
我明白了这个错误.问题是我不知道如何解决这个问题.
我的Groovy文件的一部分:
def testID = "fakeID"
response = httpRequest acceptType: "APPLICATION_JSON",
contentType: "APPLICATION_JSON",
customHeaders: [[name: 'Authorization', value: token]],
url: server+port+"/exams"+testID
Run Code Online (Sandbox Code Playgroud)
有谁知道如何让groovy接受这404?所有帮助都提前感谢!
您可以使用validResponseCodes
参数指定一系列有效的响应代码
response = httpRequest acceptType: "APPLICATION_JSON",
contentType: "APPLICATION_JSON",
customHeaders: [[name: 'Authorization', value: token]],
url: server+port+"/exams"+testID,
validResponseCodes: '200:404'
Run Code Online (Sandbox Code Playgroud)