name option in cucumber

We can execute the specific scenarios with their names matching typical pattern. For example – Consider below feature file.
 
@selenium
Feature: My feature

    @regression @sanity @critical
    Scenario: Verify softpost title
        Given I am on the www.softpost.org home page
        Then I verify that title contains tutorials

    @sanity
    Scenario: Verify yahoo title
        Given I am on the www.yahoo.com home page
        Then I verify that title contains tutorials
To execute only those scenarios with name containing “softpost”, we can use below test class. Note that we can also use regular expression as well to specify the value of scenario name.
 
package org.softpost;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "classpath:abc.feature",
        glue = "classpath:org.softpost",
        name = {"softpost"},
        plugin = "html:target/selenium-reports"
)

public class MyTest {
}                    

Web development and Automation testing

solutions delivered!!