Cucumber Introduction

 A cucumber is a tool based on Behavior Driven Development framework. This is to write acceptance tests for the web application. It allows automation of functional validation in readable and understandable format. Like to Business Analysts, Developers, Testers, etc.  Cucumber feature files can serve as a good document for all. There are many other tools like JBehave which also support BDD framework. Cucumber implements in Ruby and then extended to Java framework. Both the tools support native JUnit.  Behavior Driven Development is an extension of Test Driven Development. It is testing the system rather than testing the particular piece of code. We will discuss more the BDD and style of writing BDD tests. Cucumber used with Selenium, Watir, and Capybara etc. Cucumber supports many other languages. Like Perl, PHP, Python, Net etc. we will concentrate on Cucumber with Java as a language.

Cucumber Basics


#1) Feature Files

   Feature files are the essential part of cucumber. Which use to write test automation steps or acceptance tests. This can use as the live document. The steps are the application specification. All the feature files end with .feature extension.

 #2) Features

  This gives information high-level business functionality purpose of Application under test. Everybody able to understand the feature file by reading the first Feature step. This part is brief.

#3) Scenarios

   a scenario represents a particular functionality which is under test. By seeing the scenario user able to understand the scenario and what the test is all about. Each scenario should follow given, when and then format. This language is as “gherkin”.


  As mentioned above, given specifies the pre-conditions. It is a known state.  


  This is use when some action is to perform. We have seen the user tries to log in using username and password, it becomes an action.


  The expected outcome or result should be placed here.   Instance: verify the login is successful, successful page navigation.


  Whenever any step is to perform in each scenario placed in Background. If the user needs to clear database before each scenario then those steps put in the background.


  And is use to combine two or more same type of action.

#4) Scenario Outline

  Scenario outlines use the same test has to be performed with different data set.  

 #5) Tags

   Cucumber by default runs all scenarios in the feature files. In real time projects, there could be hundreds of feature files which are not required to run at all times.  For instance: Feature files related to smoke test need not run all the time. So mention a tag as smoke Test in each feature file. Which relate to smoke test and run cucumber test with @SmokeTest tag. Cucumber will run only those feature files specific to given tags. You can specify many tags in one feature file.

#6) Junit Runner

  To run the specific feature file cucumber uses standard Junit Runner. It specifies tags in @Cucumber. Many tags using comma separate. Specify the path of the report and type of report want to generate.

#7) Cucumber Report

  Cucumbers generate its own HTML format. Yet better reporting can do using Jenkins or bamboo tool.    

Best Online Selenium Training in Hyderabad

  Best Online Selenium Training in Hyderabad: We provide Best Online Selenium Training in Hyderabad by real time experts. We offer online & classroom selenium