I would like to get the Scenario tag details in TestNg listener to help in writing custom reports using TestcaseId & IntId for each scenario.
@priority:1 @TestcaseId:VFF-265 @IntId:615d440932e941018806cfc5 @sit-1
Scenario : Testing login is successfull
The present workaround I have implemented is to add details in scenario name and use result.getTestName() in TestNg listener and split the details from scenario name. Only issue with this implementaiton is internal ID and TC id is visible and making the testcase names long:
@priority:1 @TestcaseId:VFF-265 @IntId:615d440932e941018806cfc5 @sit-1
Scenario : [VFF-265]_[615d440932e941018806cfc5]_Testing login is successfull
When you are using qaf with TestNG runner, it will use TestNGScenario
as ITestNGMethod
implementation. TestNGScenario
is extended TestNGMethod
which has addition method getMetaData()
which will give you meta data of the test case. Any method from testng returning ITestNGMethod
or TestNGMethod
will return TestNGScenario
object.
Below is example
public void onTestSuccess(ITestResult tr) {
TestNGScenario scenario = (TestNGScenario) tr.getMethod();
Map<String, Object> metadata = scenario.getMetaData()
}
If you are working on custom reporting, best way is to implement TestCaseResultUpdator. You can refer qaf inbuilt reporters and qaf-support-elasticsearch.