What are the main file components in Cucumber?

CucumberSoftware TestingAutomation Testing

The main file components in Cucumber are listed below −

  • Feature file − This file has an extension of .feature. It comprises single or multiple test scenarios in plain text. All the scenarios are written with the keywords like Then, Given, When, And, But, Feature, Background and so on.


Feature file.

Feature: Login Test
Scenario: Tutorialspoint login validation
Given: Launch the “https://www.tutorialspoint.com/index.htm”
  • Step Definition File - This file has an extension of .java. It provides mapping of the test scenarios to the test script logic.


Step Definition file based on the above feature file.

@Given (“^Launch the \"([^\"]*)\"$”)
public void launch_application(String url){
   System.out.println("The url is : " + url);
  • Test Runner file - This file has an extension of .java. It acts as a link between the step definition file and feature file. It gives the option of selecting a single or multiple feature files. It has the path of the step definition file and the feature file.


Test Runner file

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
   features = "src/test/java/features",
public class TestRunner extends AbstractTestNGCucumberTests { }
Published on 11-Jun-2020 16:33:49