朋友们,从这种情况下,我采取以下错误响应:
**FAIL检查值为1或2|TypeError:无法读取未定义的属性(阅读“gender”)
FAIL检查值fullName|TypeError:无法读取undefined的属性(阅读'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
},
1条答案
按热度按时间wz8daaqr1#
你忘记了JSON路径中的
party
,下面的代码可以做到这一点: