How to skip a particular test method from execution in Cucumber?


We can skip a particular test method from execution in Cucumber with the help of tagging of scenarios in the feature file.

Example

feature file.

@Regression
Feature: Invoice Testing
@Smoke
Scenario: Login Verification
Given User is in Home Page
@Payment
Scenario: Payment Testing
Given User is in Payment Page

Feature file with scenarios having tags Smoke and Payment.

Example

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
@RunWith(Cucumber.class)
@CucumberOptions(
   features = “src/test/java/features”,
   glue = “stepDefiniations”
   tags = { “~@Payment”}
)

To skip the scenarios with @Payment , ~ is placed before the @Payment tag in Test Runner file.

Updated on: 11-Jun-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements