var jsonObject = xml2Json(responseBody);tests["Body is correct"] = responseBody === "response_body_string";
//getResponseHeader()方法会返回header的值,如果该值存在tests["Content-Type is present"] = postman.getResponseHeader("Content-Type"); tests["Content-Type is present"] = responseHeaders.hasOwnProperty("Content-Type");上面的方法,不区分大小写。下面的方法,要区分大小写。
tests["Status code is 200"] = responseCode.code === 200;pm.test("Status code is 200", function () {pm.response.to.have.status(200);});//5.0以上版本方法
tests["Response time is less than 200ms"] = responseTime < 200;//5.0以上版本方法pm.test("Response time is less than 200ms", function () { pm.expect(pm.response.responseTime).to.be.below(200);});
tests["Status code name has string"] = responseCode.name.has("Created");//5.0以上版本方法pm.test("Status code name has string", function () { pm.response.to.have.status("Created");});
tests["Successful POST request"] = responseCode.code === 201 || responseCode.code === 202;//5.0以上版本方法pm.test("Successful POST request", function () { pm.expect(pm.response.code).to.be.oneOf([201,202]);});
var schema = {"items": {"type": "boolean"}};var data1 = [true, false];var data2 = [true, 123];console.log(tv4.error);tests["Valid Data1"] = tv4.validate(data1, schema);tests["Valid Data2"] = tv4.validate(data2, schema);
var Json = JSON.parse(request.data);data {object}:this is a dictionary of form data for the request. (request.data["key"]=="value")
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |