Skip to content

Instantly share code, notes, and snippets.

@mlhoutel
Last active June 28, 2022 14:11
Show Gist options
  • Save mlhoutel/5b32550a4a4126031cb12b51ceb1e3cf to your computer and use it in GitHub Desktop.
Save mlhoutel/5b32550a4a4126031cb12b51ceb1e3cf to your computer and use it in GitHub Desktop.

Must be launched via the collection runner (see here)

GET

http://localhost:8080/xxx/{{id}}

Pre-request Script

const SIZE = 10000
const FROM = 10000

let ids = pm.collectionVariables.get("ids");

if(!ids || ids.length == 0) {
    ids = [...Array(SIZE).keys()].map(i => i + FROM)
}

let id = ids.shift()
console.log(id)

pm.collectionVariables.set("id", id);
pm.collectionVariables.set("ids", ids);

Tests

const ids = pm.collectionVariables.get("ids");

if (ids && ids.length > 0){
    postman.setNextRequest("http://localhost:8080/xxx/{{id}}");
} else {
    postman.setNextRequest(null);
}

pm.test("Status code is 404", function () {
    pm.response.to.have.status(404);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment