Originally posted by Alextunchii
Hi, sorry if this question is redundant here, it is, I will risk on stackoverflow, but I thought it is the best place to ask it.
I have been using Postman so much and built a lot of useful thing in it, but now need to implement one more thing.
Briefly:
Need to create test cases to test a correct records counting for every institution.
Now I handled it like that
—Collection
–Folders
-Districts(folder)
-Colleges(folder)
-Schools(folder)
-*Principal(Folder with test in Schools folder)
where requests:
POST: Create a list
var jList = JSON.parse(responseBody);
postman.setEnvironmentVariable(“list_id”, jList.data.id);
POST: Add some filters there
GET: lists/{{list_id}} -->whete in “Test” code:
var allLists = JSON.parse(responseBody);
pm.test(“test count”, function () {
const value = allLists.data.count;
pm.expect(typeof value === ‘number’).to.eql(true);
pm.expect(value > 0 && value < 999999).to.eql(true);
});
Where I take and compare the number that came out in in previous POST request
4. DELETE: delete this list
The small problem is:
for every (Folder with test) I send POST request to create a list
for every GET request, I parse body and compare the different number
I want to:
If possible in precondition in one place create a list for every folder/test
in one place as postcondition delete this list
If it possible somehow make better:
pm.test(“test count”, function () {
const value = allLists.data.count;
pm.expect(typeof value === ‘number’).to.eql(true);
pm.expect(value > 0 && value < 999999).to.eql(true);
});
in order not to write in in every GET request in “Tests” it also would be greate.
Is it possible to bring it out to collection or folder variables/environments? to make it more delicate.
I uploaded this collection with structure if my text is not clear enough:
test.zip
Thanks!