Hi!
Trying to make flexible test cases/reusable.
I have this structure:
Collection:
Folder: where login and getting token env. which then I pass to each next endpoint
==Folder: as a name for Categories(folders with tests)
====Folder(attached inside) with calls
====Folder(attached inside) with calls
====Folder(attached inside) with calls
(this structure above - folder with categories can be duplicated and rising wider, now it more than 20 of"Folder(attached inside) with calls"
In every ====Folder(attached inside) with calls
I have these endpoints inside:
POST: create a list
POST: add filters
GET: get information with a count on this list
DELETE: delete this list
In POST create list I parse body on these parameters
var jList = JSON.parse(responseBody);
postman.setEnvironmentVariable("list_id", jList.data.id);
postman.setEnvironmentVariable("segment_id1", jList.data.segments[0].id);
postman.setEnvironmentVariable("targeting_crit_id1", jList.data.segments[0].targetingCriteria[0].segmentCriteriaId);
list_id - pass to DELETE list and GET count
segment_id1, targeting_crit_id1 - pass to POST add filters
In GET: get information with a count on this list - I have this test:
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);
});
Questions:
-
Can I get POST: create a list endpoint brought out as precondition for every test scenario in order not to put Create and Delete a list in every folder (stupid copy-paste)
-
Can I get this test or just value > 0 && value < 999999 (number range: 0 - 999999) added as separate global variable or environment for every different test, something like that:
-
geo: value > 0 && value < 999999
-
job: value > 0 && value < 30000
-
inst: value > 0 && value < 40444 - in order not to hardcode the different number in every endpoint “tests”
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); });
Please, give an advice, is there any better practise?