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

1 comment:

  1. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at selenium Online Training blog


Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...