Accessing arguments/parameters of an Allure report during execution?

2.2k views Asked by At

In the testing framework we are using allures .addArgument method to add a parameter to the report for the name of team which owns a particular test.

AllureReporter.addArgument('teamName', 'myTeam');.

Many tests have already been written, some with this argument missing and I want to know how I can access the argument values which have been set on an active allure report object while the test is running (maybe in the afterTest hook) so I can automatically add a default team if argument is missing.

Another use case would be to check if any allure steps are open at the end of a passing test and end them if so.

Report looks like enter image description here

1

There are 1 answers

2
Knight Industries On

According to the implementation of addArgument, this should work:

const currentTest = allure.getCurrentTest();
const param = currentTest.parameters.filter(p => p.kind === 'argument' && p.name === 'teamName');
if (!param) {
  currentTest.addParameter('argument', 'teamName', 'myTeam');
}

(untested)