2

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

DublinDev
  • 2,318
  • 2
  • 8
  • 31

1 Answers1

2

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)

Knight Industries
  • 1,325
  • 10
  • 20
  • I appreciate your answer, it appears that the version of allure which WDIO testing framework has implemented does not operate in this same manner and getCurrentTest is inaccessible for me – DublinDev Apr 12 '22 at 09:21
  • Try: `const currentTest = allureReporter['_allure'].getCurrentTest();` – Knight Industries Apr 12 '22 at 13:24