What is a feature file in Cucumber? What does feature file consist of?

A feature file must provide a high-level description of an Application Under Test (AUT). The first line of the feature file must start with the keyword ‘Feature’ following the description of the application under test.

A feature file may include multiple scenarios within the same file. A feature file has the extension .feature. A feature file in Cucumber is a starting point of the Cucumber tests execution. 

The feature files exist in the feature folder. To add a feature file in the project, the scenario or feature to be automated has to be identified before, then feature file is added and then test runner class will be created. Now step definitions have to be linked with feature files.

The scenario steps will then be executed during automation. In this file, the description of the tests will be available in the descriptive language. A feature file can have a single or multiple scenarios but normally it contains a group of scenarios. The feature file format will be like file_name. a feature where a single file contains a single feature.

Feature file in cucumber consist of parameters or conditions required for executing code, they are:

  • Feature
  • Scenario
  • Scenario Outline and Examples
  • Given
  • When
  • Then
  • And
  • But