Elimizde şöyle bir ön script olsun
function randomString() {...}pm.collectionVariables.set('randomEmailPrefix', randomString());
Bir istek gönderelim
{
  "notificationEmail": "{{randomEmailPrefix}}@gmail.com",
  "customerType": "INDIVIDUAL"
}
Test metodlarını şöyle yaparız
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});
pm.test("Customer has created successfully", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData).is.not.null;
    pm.expect(jsonData.id).is.not.null;
});
pm.test("Response has a valid json body", function () {
     pm.response.to.be.ok;
     pm.response.to.be.withBody;
     pm.response.to.be.json;
});
pm.collectionVariables.set("createdCustomerId",  pm.response.json().id); 
Hiç yorum yok:
Yorum Gönder