Control the flow, repeting some tests

I hava a collection with tests A, B, C, D, E, F. The test D must be executed several times, so it will execute A, B, C, D, D, D, D, E, F.

I followed the trick like this :

const currentTest = ‘D’;
const nextTest = ‘E’;

const entity = JSON.parse(pm.collectionVariables.get(‘currentEntity’));
pm.test(Testing D with entity ${entity} status code is 202, () => {
pm.response.to.have.status(202);
});

let entities = pm.collectionVariables.get(“entities”);
if(entities) { entities = JSON.parse(entities); }
if (entities && entities.length > 0){
postman.setNextRequest(currentTest);
} else {
postman.setNextRequest(nextTest);
}

I would like to know if it was possible to dynamically get the name of the current test (D) and the name of the next test (E).

The goal is to be able to change the workflow without having to change “currentTest” and “nextTest” and making errors.

I saw “setNextRequest”, is there is a way to have something like “getCurrentRequest” and “getNextRequest” ?

Thank you community,

See you,
Kin

Sorry, I’m just tired.

I found “postman.setNextRequest(pm.info.requestId);” if I want to recurse and no needs to set “postman.setNextRequest(nextTest);” if I want let the runner going to the next.

I don’t know why I would complicate my like :wink:

Thank you,
Kin