Here’s an outline with best practices for making your inquiry.
My question:
I have a response body with following fields and these values are coming from DB and values changes every time we hit send button(values are dynamic). How can I validate the response in the postman test script.
Please help.
Thanks!
Could you help me to understand, what are you hoping to validate if the response is random every time?
You mentioned global/collection variables in the title; does this mean that you are setting the values using a POST with random elements (e.g. POST with email: {{$randomEmail}}) and you want to know how to pass these values using variables into a subsequent GET request, so that you can validate that the GET request is bringing back these details?
The challenge with validating these values is determining what the ‘expected’ value should be, if they differ each time. Almost anything is possible if the requirements are understood
For example, joinDate: Would this always be today’s date? Or would it always be X days in the past?
Again, for memberId: Do you simply want to validate that you get any number in the response?
Much of this could be achieved with either Schema validation, or you could write more long-form tests such as the below:
pm.test("Member ID is numeric", function () {
pm.expect(jsonData.memberId).to.be.a("number");
});
Yes Join date could be anything it depends on members joining our site. Is it only possible to validate schema or is there any other way to compare the data as well.