Introduction To BDD & Cucumber Framework

What is BDD?

  • It is also known as Behavior Driven Development
  • It is an Agile Software Development Process
  • It encourages team collaboration
  • It is Inherited from TDD principles
  • It uses simple domain specific languages similar to English
  • Some of the popular BDD tools are Cucumber, Jbehave, Specflow, Jasmine

What is Cucumber Framework?

  • It is a popular BDD Framework
  • It uses Gherkin language to write business specifications
  • It contains Features, Step Definitions and Test Runner
  • It supports languages like Java, JavaScript
  • It can be easily integrated with Automation tools like Selenium
  • It can be integrated with popular test frameworks like TestNG or Junit
  • It has inbuilt Reporting Capabilities

Different Components in Cucumber Framework:

Feature Files:

Feature: User is able to login into Gmail Page

Scenario: User can login with valid username and password

      Given User enters valid username

      And User enters valid password

      When User clicks on Submit button

      Then Inbox page is displayed

StepDefinition Files:

@Given("User enters valid username")
public void enterUsername(){
}

@And("User enters valid password")
public void enterPassword(){
}

@When("User clicks on Submit Button")
public void clickSubmit(){
}

@Then("Inbox page is displayed")
public void verifyPage(){
}

Runner File:

@CucumberOptions(
plugin = {“pretty”},
features={“src/test/resources/features”},
glue = {“src/test/java/StepDefs},
tags=“@regression”
public class TestRunner{
}

 

Share

Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!