I am starting my journey using chai, I am facing some difficulties and I hope to be clear so that you can understand. I am validating the return of a request, where I want to create two validations according to the returns.
STEP 1
pm.test("If there is no login for the queried ID, you should return the message (ID has NO record))", function () {
pm.response.to.have.status(200);
});
or
STEP 2
pm.test("If there is a login for the queried ID, the message must be returned (ID has registration in the system)", function () {
pm.response.to.have.status(404);
});
If the return is step 2, I abort the validation and move on to the next iteration.
To me, this sounds like a positive and a negative test, so I would keep them as separate requests.
Do you know if there is a login for the Id you are querying before the test runs?
I think what you’re looking for is to just surround these tests in an if/else block
if(idHasLogin){
pm.test("If there is no login for the queried ID, you should return the message (ID has NO record))", function () {
pm.response.to.have.status(200);
});
} else {
pm.test("If there is a login for the queried ID, the message must be returned (ID has registration in the system)", function () {
pm.response.to.have.status(404);
});
}
Yes, there are two cases, one negative and other positive.
However, the test it is:
If the customer does not have a record, I continue testing, othwise, if it has a record, the validation ends, skipping to the next interaction
Marcelo, please let us know about your collection whats in there, it would be good to know
to move to next request You have to use setNextRequest("continuetesting"), is that what you mean ?
1st validation:
I check if the ID has a record, if it has no record, the API includes that record and continue with the other 4 validations.
2nd validation:
check if the ID has a record, if it has a record, finish the test, and skip to the next Iteration (I’m execute the collections via Runner))