PostMan做接口自动化测试

时间:2022-09-16 05:56:04
try{
var jsonData = pm.response.json();
} catch (e) {
   console.log("No body");
}

pm.environment.unset("fileID");
pm.environment.set("fileID", jsonData.id);

pm.test("Status code is 200", function() {
    pm.response.to.have.status(200);
});

pm.test("Status code name has string", function() {
    pm.response.to.have.status("OK");
});

pm.test("Taxonomy name is correct", function() {
    pm.expect(jsonData.name).to.eql(pm.environment.get("adminMasterTaxName_timeStamp"));
});

pm.test("Country code is correct", function() {
    pm.expect(jsonData.country).to.eql(pm.environment.get("country"));
});

pm.test("LiveRT is correct", function() {
    pm.expect(jsonData.liveRT).to.eql("DataXu");
});

pm.test("builtAt is correct", function() {
    pm.expect(jsonData.builtAt).to.eql("Acxiom");
});

pm.test("matchKeys is correct", function() {
    pm.expect(jsonData.matchKeys).to.eql("PII");
});

pm.test("scoredOver is correct", function() {
    pm.expect(jsonData.scoredOver).to.eql("List");
});