Cucumber and TestCases Specifications in Behaviour Driven Development

Posted By : Abhishek Rathore | 27-Jan-2021
 
 
 
 

What is Cucumber?
 

Cucumber may be a testing approach that supports Behavior Driven Development (BDD). It explains the behavior of the appliance during a simple English text using Gherkin language.

 

TestCases Specifications in Behaviour Driven Development

 

Step 1:
 

Testcases should be defined at a Business level by following a ubiquitous language
Ubiquitous language is a (semi-)formal language that is shared by all members of a software development team — both software developers and non-technical personnel.

Syntax :
In order to(Achieve something)-> Business outcome
As a (Role)
I want to Do this

Example:
In order to Pay Credit Card Payment
As a NetBanking sole owner who has credit section access
I want to Navigate to the credit card section, Enter the amount and process my Payment


Step 2:
 

Its time to Decide what Test cases are sufficient to certify Business Scenario working

The syntax for Writing Testcases:
Given (what you need to have to perform an action), -Prerequisites
When (performs an action)- Action
Then (the aspired result for the user).- Validation

Example:

 

Also Read: Using Jmeter for Performance Testing

 

Feature file:-

Feature: Application login



Scenario: Home page default login
Given User is on netbanking landing page
When User login into application with username "jin" and password "no"
Then Home page is populated 
And Cards displayed are "true"

 

Also Read: Protractor over Selenium In Automation testing

 

StepDefination file:-

package stepDefinations;


import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.And;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
public class stepDefination {

    @Given("^User is on netbanking landing page$")
    public void user_is_on_netbanking_landing_page() throws Throwable {
        System.out.println("given statement");
    }

    @When("^User login into application with username \"([^\"]*)\" and password \"([^\"]*)\"$")
    public void user_login_into_application_with_username_something_and_password_something(String strArg1, String strArg2) 
    throws Throwable {
        System.out.println(strArg1);
        System.out.println(strArg2);

    }

    @Then("^Home page is populated$")
    public void home_page_is_populated() throws Throwable {
        System.out.println("validated homepage");
       


    }

    @And("^Cards displayed are \"([^\"]*)\"$")
    public void cards_displayed_are_something(String strArg1) throws Throwable {
        System.out.println(strArg1);


    }

}

 

TestRunner file:-

package cucumberOptions;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
		features = "src/test/java/features", //path of feature file
		glue = "stepDefinations"             //Package of stepDefination file
		)

public class TestRunner {

}

 

Also Read: An Overview of Test Design Techniques

 

Advantages:


-Can be used as a Standard Template wherein every QA can adhere to a single common standard of defining Testcases
-Each Scenario reflects a Business Value
-We can estimate the Test coverage that happened for Each Business outcome by going through Test Cases
-The annotations can be tagged to Selenium Automation for executing the Business Testcases
-For both Manual and Automation testing we have this Common Standardised Testcase template

 

Why Choose Oodles Technologies For DevOps Solutions?

 

We are seasoned DevOps solutions and service providers with vast experience in providing full-scale DevOps solutions for varied business requirements. Our team of DevOps professionals formulates effective strategies to strengthen your enterprise IT infrastructure and enhance operational efficiency. Our 360-degree DevOps solutions and services accelerate the software development lifecycle and ensure faster delivery with continuous deployment. For project related queries, reach us out at [email protected].

Related Tags

About Author

Author Image
Abhishek Rathore

Abhishek is ISTQB certified Software Tester with skills in Manual testing, Automation Testing and SQL. He has good analytical skills and ability to solve the problems.

Request for Proposal

Name is required

Comment is required

Sending message..