serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

<Question> Is there a way to get all the Tags of scenario during run time in stepdefinition?? #199

Closed srinivasbudh closed 5 years ago

srinivasbudh commented 5 years ago

I have a scenario where I want to manage some test data based on the scenariotags, but during runtime I'm unable to scenario tags, Is it possible to fetch tags while running @Step methods?? if yes, can anyone help with it??

Thanks in advance

wakaleo commented 5 years ago

You might be able to access the tags via the StepEventBus, though I don’t have the code in front of me.

wakaleo commented 5 years ago

Try

StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().get().getTags()
srinivasbudh commented 5 years ago

Thanks for the quick response, will check and confirm shortly

srinivasbudh commented 5 years ago

Thanks a Lot @wakaleo Solution you provided works great

StepEventBus.getEventBus().getBaseStepListener().latestTestOutcome().get().getTags()

returns set of TestTag's. upon iterating through the set and using getName() methods I'm able to get the exact Tag that I'm looking for.

Thanks a lot for you help