vendredi 17 juillet 2020

Using Javascript to write test data that has been POST/PUT between endpoints

I am using Postman for test development for APIs and would like to have a format of testing in my collection as follows:

1)Get x(set of data) 2)POST x' 3) GET x' 4)PUT x'-->y 5)GET y 6)DELETE y 7)GET y(which should be deleted)

My problem stems from step 3 in which I have to retrieve the pinpointing the x' posted in step 2. Since the data set has around 40 elements for each object being posted/put, would I have to test for each element to ensure it was posted correctly? Would I have to set the x' as global variable to use throughout the test for the collection? I have the typical "test for 200" tests for each step already.

tests["status is 200"] = (responseCode.code === 200);

if (responseCode.code == 200) {

try {
    
    var res = JSON.parse(responseBody)
    
} catch (e) {
    
    console.log(e);
    
}

}

Aucun commentaire:

Enregistrer un commentaire