- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the main file components in Cucumber?
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.
Example
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.
Example
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.
Example
Test Runner file
import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import cucumber.api.testng.AbstractTestNGCucumberTests; @CucumberOptions( features = "src/test/java/features", glue="stepDefinations") public class TestRunner extends AbstractTestNGCucumberTests { }