javaseleniumselenium-webdrivercucumber-junitcucumber-java

How to run multiple tags from testrunner class file in cucumber framework using @tags?


@RunWith(Cucumber.class)
@CucumberOptions( plugin = {"pretty","html:target/html/automation"},
                features = {"resource/***.feature"},
                glue={},
                tags={"@login","@Products"}
        )

This is my feature files

@login

Feature: Login to Application

Scenario: this is verify the application is logged successfully Given Navigate to Panasonic application Then Verify the title of the application Then Logout the application

@Products

Feature: Login to Application

Background: user should be navigate to home page of application

Given User login to home page with valid credentials

When click the catalog link on home page

Scenario : To verify whether able to create more than ten products in products page

And check the sub menu of catalog is displaying in header

And check the My product catalog table


Solution

  • Here's a sample cucumber Junit runner template:

    @RunWith(Cucumber.class)
    @CucumberOptions(features = { "classpath:features/*.feature" }, glue = "packagename(s) or class name(s) containing the step definitions", plugin = {
            "pretty:target/prettyReport.txt", "html:target/cucumber", "json:target/cucumber.json", "rerun:target/rerun.txt",
            "junit:target/junit-report.xml", "testng:target/testng-output.xml" }, monochrome = true, tags = {"~@Ignore"})
    public class FeatureRunnerTest {
    
    }
    

    Hope this helps!!
    EDIT: "~" symbol..is used for negation..that is run all the features except one's marked with Ignore tag..On the other hand u can specify list of tags in the tags attribute comma seperated to run only those tests