cucumber tags based on maven profile

Viewed 3243

I am trying to run specific Gherkin scenarios based on the variable @tags(if it is possible). For example, if my profile is "dev" I want to run scenario 1 and if profile is "qa" I want to run scenario 2. I can get the profile value in my java class. I can also pass the tags in the command line and run it as mentioned here. But that is not something I am looking for. For example:

@QA
Scenario:I do x and check y
  Given I do abc
  Then the response is 200
@DEV
Scenario:I do y and check x
  Given I do cde
  Then the response is 500

I am getting the profile value in java class as

System.getProperty("myprofile");

How can I set the tags for cucumber based on my profile so that I can run specific test in specific environment? Basically, I do not want to pass the tags in command line rather want to set it based on my profile. Would it be possible? If not, what would be the best way?

1 Answers
Related