[Cucumber] Re: [Cucumber-JVM] How to identify trigger tag from Scenario api
(too old to reply)
Justin Radcliffe
2017-07-21 12:49:23 UTC
Raw Message
public static *Login *runThrough(Scenario scenario) {

* Login login = null*;

for (String tag : scenario.getSourceTagNames()) {
if (tag.startsWith("@small")) {
l*ogin = new LoginSmallImpl()*;

if (tag.startsWith("@medium")) {
l*ogin = new *LoginMediumImpl *()*;
if (tag.startsWith("@big")) {
l*ogin = new *LoginBigImpl*()*;

return login;

You could try something like this but you may need to know if you already
used one of the tags if you want to test this 3 times with different login
types or have 3 scenrios with one of those tags each.

Enter code here...
Hi there,
I have a scenario which applies to different sizes of browser. According to the trigger tag, I want to instantiate a different implementation which implements the same interface.
@small @medium @large
Scenario: Login
Given I am on the login page
When I login with a valid username and password
Then login should be successful
public class LoginSteps
public void small(Scenario sc)
public void big(Scenario sc)
@Given("^I am on the login page$")
public void i_am_on_the_login_page() throws Throwable {
@When("^I login with a valid username and password$")
public void i_login_with_a_valid_username_and_password() throws Throwable {
@Then("^login should be successful$")
public void login_should_be_successful() throws Throwable {
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+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.