New to Postman and starting to get into more complex testing base on the body responses. My aim is to test several arrays of data from the body response.
Questions is how best to either loop through testing or by doing if/else or try catch conditions when the data has the same properties but different values in each separate array of data?
Example: AccountID shows in all arrays but the numbers obviously change in each. I want to account for those to not be null. I know I can do a pm.expect (json.data.AccountID).to.be.not.null but I was looking for more efficient way to loop through and conditionally check each array output? Maybe I’m making this harder than it needs to be??
{
“AccountID”: 123485,
“AssociateNumber”: 123456,
“AssociateType”: “Account”,
“AccountType”: “Business”,
“DisplayName”: “Test”,
“FirstResDate”: “2011-07-06T00:00:00”,
“LastResDate”: “2011-09-14T00:00:00”,
“LastContactDate”: “2010-12-26T00:00:00”,
“PricingLevel”: “Executive”,
“ActiveFlag”: false,
“CreatedBy”: “Conversion”,
“CreatedDate”: “2010-12-26T07:48:34.827”,
“ModifiedBy”: “Test”,
“ModifiedDate”: “2020-09-02T07:27:29”
},
}, {
“AccountID”: 123485,
“AssociateNumber”: 123456,
“AssociateType”: “Account”,
“AccountType”: “Business”,
“DisplayName”: “Test”,
“FirstResDate”: “2011-07-06T00:00:00”,
“LastResDate”: “2011-09-14T00:00:00”,
“LastContactDate”: “2010-12-26T00:00:00”,
“PricingLevel”: “Executive”,
“ActiveFlag”: false,
“CreatedBy”: “Conversion”,
“CreatedDate”: “2010-12-26T07:48:34.827”,
“ModifiedBy”: “Test”,
“ModifiedDate”: “2020-09-02T07:27:29”
},