On Thursday, 9 April 2015 at 16:16, Simon P. wrote:
Does anyone know if there is a way to get all the tags from a .feature file and use them in my .java step definition file?
I saw there are some gherkin.formatter.model.Tag and gerkin.formatter.model.Scenario libs that exist and maybe .getTags() can be used, but how do I reference the specific Scenario I want?If that's not possible, do I need to convert my Gherkin file into json first?I've searched and haven't found anything about this.example:@HelloWorld @aliveScenario: Say helloWhen I say hello!Given the world is aroundThen the world says hi!stepdefinition.java// TODO: Is there a way to get all the tags in a feature file?@Before("@alive")public void beforeScenario(){// print a list of tags in this .feature file}
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
example:@HelloWorld @alive @happy @sad
Scenario: Say helloWhen I say hello!Given the world is aroundThen the world says hi!stepdefinition.java
// TODO: Is there a way to get all the tags in a feature file?
@Before(<a list of tags>)
public void beforeScenario(){// print a list of tags in this .feature file
}
Tags are also a great way to “link” your Cucumber features to other documents. For example, if you have to deal with old school requirements in a different system (Word, Excel, a wiki) you can refer to numbers:
@BJ-x98.77 @BJ-z12.33 Feature: Convert transaction
Yeah that's right, each of the 'requirementIds' would be a tag, and that way I'd know what requirements are needed for that test case.Do you a way to get a Scenario object so I can get all the tags for a scenario?
public void before(cucumber.api.Scenario scenario){
for(String tag : scenario.getSourceTagNames()){
System.out.print("Tag: " + tag);
}
}