用Postman验证数据



朋友们,从这种情况下,我采取以下错误响应:
FAIL检查值为1或2 | TypeError:无法读取未定义的属性(读取'性别')
FAIL检查值fullName | TypeError:无法读取未定义的属性(读取'fullName')

const response = pm.response.json();

pm.test("Check value is either 1 or 2", function() {
pm.expect(response.naturalPerson.gender).to.be.oneOf([1, 2]);
});
pm.test("Check value fullName", function() {
pm.expect(response.naturalPerson.fullName).to.eql("Bia Teste");
});
{
"party":{
"partyId":1555,
"partyExternalId":"0",
"partyType":1,
"partyIdentification":{
"partyIdentificationType":1,
"documentNumber":"16250560017"
},
"naturalPerson":{
"fullName":"Bia Teste",
"gender":2,
"pronoun":1,
"maritalStatus":{
"maritalStatusSituation":2
},
"filiation":{
"fullNameFirstFiliation":"Ana Souza",
"firstFiliationType":1,
"fullNameSecondFiliation":"João Souza",
"secondFiliationType":2
},

输入图片描述

您在JSON路径中忘记了party,可以这样做:

pm.test("Check value is either 1 or 2", function() {
pm.expect(response.party.naturalPerson.gender).to.be.oneOf([1, 2]);
});
pm.test("Check value fullName", function() {
pm.expect(response.party.naturalPerson.fullName).to.eql("Bia Teste");
});

相关内容

  • 没有找到相关文章

最新更新