Cucumber BDD Framework – Is so Famous, But Why?

Introduction to Behavior Driven Development (BDD) in Cucumber testing.

Cucumber Testing tool is used for behavior-driven Development i.e. BDD approach. Let us try to understand BDD in layman’s language.  Consider that the developer is building a Cash Transfer module as a part of an online banking application for a particular bank. In order to test the Cash Transfer Module, the developer has multiple ways to test the end-to-end functionality where one of the approaches has explained below. This is also known as Cucumber BDD Framework.

  1. Cash transfer can only happen when the source account in the bank has sufficient money in it.
  2. Cash transfer should happen from source account to target account in the same or different bank only when the target account details are valid.
  3. Cash transfer can happen after the transaction has passed the security authentication i.e. transaction password, OTP, etc.
  4. Cash transfer should not happen on the non-business day but the system should allow a standing transaction for the next business day.
  5. Cash transfer from source account to target account can happen on the same as well as future business days only. Past dated cash transfer should be restricted in the online banking system.
cucumber bdd framework

Such tech scenarios will add more complexity when the conditions such as transfer of Y amount of money for Z days/months have included. Also, the condition such as to stop the money transfer when the account balance of source account has reached a certain threshold. These scenarios add more complexity to the testing as they are elaborated in detail. 

A developer will keep on facing such complex situations for which current or existing modules code needs to be altered in order to accommodate the requirements. Such scenarios will make the developer spend an exhaustive effort towards functional testing, in order to ensure that the current scenario is not violating the existing tested scenarios. Therefore, quick development as making progress towards complex test scenarios and altering code in parallel will result in an overall ineffective functional testing of the system. But such issues can be overcome with the help of BDD i.e. Behavior Driven Development. It delivers a simple testing process to the developer to ensure that any code change made for implementing a requirement is not violating or breaking the existing functionality. This is possible by writing the test cases into Given-When-Then steps as supported by BDD. Let us understand it with the help of an example.

 

Cucumber Testing Example

 Example of Cucumber BDD Framework Given-When-Then steps in cucumber language.

Given-When-Then

Feature: OnlineCashTransfer

  I transfer cash from source account to target account

  Scenario Outline: transfer from source_account to target_account
    Given that a cash transfer module in online banking has been developed
    And I am accessing the system with valid authentication
    When I should trigger transfer with ample balance in the source_account
    And target_account details are valid
    And security authentication for password and OTP has passed
    And click on the send button has completed
    Then cash amount should be transferred successfully to target_account
    And the event should be logged in the log file
    Examples:  

After going through the above test cases to build a scenario using the Given-When-Then approach. It is very clear that it is very easy to read, write, and understand the test cases. Even a person from non-technical background can grasp what is being tested or developed here. Also, such a test scenario can easily be modified to add or remove more options for the required conditions which can be validated all with existing test cases in order to test the complete test scenario.

 

Cucumber Testing Tools

 Cucumber tool supports BDD or Behaviour Driven Development. The tool delivers a simple way to write test cases that can be easily understood by any person from any kind of background. Cucumber uses Ruby programming language bit it also supports other languages such as Java, Scala, Groovy etc

Cucumber BDD Framework follows a structure in terms of roles and responsibilities where the users such as product team, and Business Analyst begin to write the scenarios or acceptance tests in order to describe the behavior of the system from the customer’s perspective. Such system behavior descriptions can be further reviewed, and sign-off by the product owner before it could have supplied to the developer for the actual development.

 

Pros and Cons of Cucumber Testing Tool

  1. Cucumber tool supports BDD testing which focuses on the end-user experience.
  2. It allows an early involvement of the business stakeholders which are from a non-technical background and can understand the system after going to the BDD test cases.
  3. It supports a quick and easy setup of the test cases along with very easy execution of the test cases or test scenarios. 
  4. It offers an efficient tool for testing.
  5. The test case writing style supports the code reuse in the tests.
 

Comparison between Cucumber, Selenium, and HP ALM (UFT)

In the below comparison table, we will outline the differences between these three popular testing tools.

CucumberSeleniumHP ALM (UFT)
It is free to use in term of cost.It is free to use in terms of cost.It requires a licence to be purchased and hence not free to use in terms of cost.
Cucumber Framework provide support to other language such as Ruby, Java, Scala, Groovy etc.Selenium Framework provide support to other language such as Ruby, Java, Scala, Groovy etc.QTP supports VB scripts only.
It is a behaviour driven testing tool.It is a Functional and Performance i.e. Selenium Grid testing  tool.It is a functional testing tool used for test automation.
Plugins in Cucumber operates fast.Plugins in Selenium operates slower than Cucumber but faster than QTP.Plugins in QTP operates slower than both Cucumber and Selenium.
It supports only Web Environment.It supports web, desktop and any client server based application testing.It supports only web application testing
In Cucumber, the writing of cucumber automation test steps are the joint effort of both developer and tester.In Selenium, the writing of automation test steps are the joint effort of both developer and tester.In QTP, the test cases are written only by tester.
 

Over to you

In this chapter, we discussed the Behaviour Driven Development (BDD) approach and the Cucumber testing tool used for BDD. Also, we compared all three popular tools i.e. Cucumber, Selenium, and QTP/UFT which are widely used in the software industries for software testing.

cucumber testing

Cucumber Testing Tool Course Syllabus


TutorialCucumber BDD Framework – Is so Famous, But Why?
TutorialDownload and Install of Cucumber tool
TutorialMy first automation using Cucumber tool
TutorialExample on Cucumber Feature File and Step Definition
TutorialHow to write Gherkin Test in Cucumber
TutorialExample project to Create your First Cucumber Script
TutorialInterview Questions

⇓ Subscribe Us ⇓


If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:


 

Check email in your inbox for confirmation to get latest updates Software Testing for free.


  Happy Testing!!!
 

Leave a Comment

Share This Post