我知道可以使用以下代码片段简单地对json响应执行此操作:
pm.response.to.be.json;
XML呢?
pm.test("The body of the response is a valid XML", function () { pm.response.to.be.withBody; pm.response.to.be.xml; // â });
有很多种方法,这里就是一种。
使用内置函数将XML正文转换为JSON对象 xml2Json . 如果函数返回值,则响应有效,否则无效。
xml2Json
pm.test("The body of the response is a valid XML", function () { pm.expect(xml2Json(responseBody)).to.exist; });