A feature is a functional part of the software application that the user interacts with, such as login, registration, search, etc.
A feature file is a plain-text file in a BDD automation framework. In the Cucumber framework, the feature file defines test scenarios in a clear and structured format using Gherkin syntax. Each test case is written as a Scenario, and the steps are described using the Given, When, Then, and other Gherkin keywords.
Adding a Feature File to the Java-Maven Project
1. Navigate to: src/test/resources in the project. (or create the resources folder inside the test folder if it doesn't exist)
2. Inside resources, create a folder named features.
3. Inside the features folder, create a new file named after the page or feature, with the .feature extension.
For Example: login.feature, homepage.feature
Writing Test Cases inside a .feature file
Inside the .feature file, write the test case of the feature using Gherkin syntax.
If you're unfamiliar with Gherkin, refer to the Introduction to Gherkin Syntax section for a quick refresher.
Here is the example feature file for login.feature
Best Practices of Feature File
The filename should end with .feature
Use meaningful scenario names
Keep one feature per page of the application for clarity
Group related scenarios inside the same feature