Search code examples
javabddcucumber-java

Modify CucumberOptions tags when running Cucumber in Java


I was wondering if there was a way to modify CucumberOptions tags while Cucumber is running?

I'm not sure if this is possible or not but I was wondering if there was a way to modify tags while Cucumber is running. In my example code, I would like to add another tag "@Login" once Cucumber runs. I am trying to setup a configuration where I can select which feature I want to run without going into the Runner class.

Settings Class

 String AddTags = "@Login";
          set = new HashMap<String, String>(){
            {put("Tags", AddTags);

Runner

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class) 
@CucumberOptions (features="src/test/cucumber/features", 
tags = "@Smoke",  //For instance, once cucumber runs I want to add 
tag "@Login". //So something like adding Settings.set.get("Tags");
plugin = {"pretty", "html:target/cucumber- 
htmlreport","json:target/cucumber-report.json"}
)
public class Runner {

}

Not sure if this is possible with Cucumber but wanted to ask.


Solution

  • What about using a list of tags?

    tags = "@Smoke,@Login"