Saturday, January 6, 2018

What are Runner Class, Feature File, Scenario and Step Definitions in Cucumber?

There are four main entities to be learned in Selenium - Cucumber automation, namely,
  • Runner Class
  • Feature Files
  • Scenarios
  • Step Definitions
Runner Class: Cucumber use Junit runner class to run the tests. It uses @RunWith junit annotation that tells Junit to run the tests as cucumber tests. Cucumber options or configuration of Feature files, Step Definitions and Reporting will also be specified in the runner class.

Feature Files: A file with extension '.feature' is called Feature. A feature file contains a Feature. And  feature always starts with 'Feature' keyword in the feature file and it contains one or more scenarios.

Scenarios: Each test case is a scenario. And a scenario starts with 'Scenario' keyword in the feature file. And each scenario contains one or more steps.

Step Definitions: The steps written in the feature file are simple English sentences about the action to be performed but there is no actions defined.  Each step in the scenario will have a definition in Step Definition file. Step and Step Definition will be connected with each with a reference.

That is pretty much theoretical, don't worry about the definitions even if you are not clear with, once we write our first test case using Cucumber the clouds will disappear. 

The execution flow goes as depicted in the below picture. Runner class tell us about which features to be executed and other cucumber configurations. Scenarios will start executing from the feature file , each step in the scenario calls the its step definitions from the Step Definition file and finally results report.

Please comment your queries and suggestions on this topic. Thanks for reading!!
 #seleniumbabu #HappyLearning

No comments:

Post a Comment

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...