What's on our minds at Qentelli

On August 18, 2016, Posted by , In QentoLog, By , , With Comments Off on Business Driven Testing – The way Continuous Delivery

In a fast paced environment, it is very important to have Continuous Delivery as the theme to deliver your releases as customers demand and also with the highest levels of quality. To get to continuous delivery continuous development and continuous testing backed by continuous integration are a first step. To achieve continuous development and testing, In this note we use Business Driven testing which is a piece of the larger methodology by Qentelli called Quality Driven Development, as the key first step. Let us now take a look at what it entails.

Meet Business Driven Testing (BDT) the way to Leverage ATDD Principles for Continuous Delivery

BDT is a component of Quality Driven Development (QDD™ by Qentelli). Behavior Driven Tests focusing on high level design not the technical implementation and not the technical terminology.

BDT ensures test cases/stories are written in Given – When – Then style that makes it a natural language which are easily understandable to any persons like technical/non-technical.

BDT is open source framework available in many languages and it will be support different platforms: Cucumber, JBehave, NBehave, Speckflow, Behat and Twist.

We have to write the stories in the following format:

  • Given <An initial context>
  • When <Event Occurs>
  • Then <An outcome should be observed>

Involvement into BDT

Stakeholders or Users, Business Analysts, Testers, Developers will involve and perform their Respective roles.

blog-imge-1

BDT Notation:

  • Scenarios are designed to test.
  • Scenarios are grouped into features
  • Each scenario consists of   –Given   –When   – Then

BDT Process Flow:

blog-imge-2

Business analyst identifies the features as per the customer requirements.

  • Tester use cucumber features as test scenarios.
  • Tester writes test cases as behavior driven cucumber scenarios(user stories).
  • Developer writes code that makes test cases pass.
  • Test cases get automated by the testers.
  • Code is deployed and test executes their automated tests.
  • Bugs will get fixed, automated tests run as regression tests.
  • When done customer/user accept the software (Acceptance and quality criteria met).

Advantages and Challenges:

  • Easy understandable by the stakeholders or users because tests in the form of plain text.
  • Users and business Analysts can participate in test cases review process and give their feedback to enhancement.
  • Behaviour driven tests are easier to modify and hence.
  • BDT tools are open source which reduces the source of investment.
  • Very easy to maintain.
  • We can implement in mobile testing.

BDT with Cucumber Framework Implementation:

If we get the business requirement or user story from the user, the user story requires to define every piece of requirement in terms of:

  • who is the primary stakeholder for a particular requirement?
  • what effect does the user wants from this requirement?
  • what business value would the user get if the aforesaid requirement is achieved.

Consider the below example to understand the above.

As a user of the Gmail, I want to find a Gmail link in Google Search Page, So that I can see the Gmail login page.

We have to write the above behaviour in feature file format (-Given -When -Then format).

  • Given describes the pre-requisites for the expectation
  • When describes the actual steps to carry on the effect of the expectation
  • Then describes the verification that the expectations were met.

Feature File: Test.feature

blog-imge-3

Feature can contain multiple scenarios and scenarios can contain steps.

We have to follow the steps to execute and run steps with cucumber:

  1. Create a project directory: In that create 3 folders one for feature files, one for java libraries and one for step definition file as below.4
  2. Copy the Test.feature file in features folder. Test.featureblog-imge-4
  3. Get the following cucumber jar files and copy into jars folder6
    1. Now we have to compile the feature file from command line for step definition methods generation. Open command prompt and go to the project directory and give the command as: Java –cp “jars/*” cucumber.api.cli.Main –p pretty features7

Press enter then we will get the step definition methods as follows:

8

Copy the selected three methods and paste into StepDefinition.java file.

Prior to that just create StepDefinition.java file as

package step_definition; // we have to give the folder name as package

import cucumber.api.java.en.Given;

import cucumber.api.java.en.Then;

import cucumber.api.java.en.When;

import cucumber.api.PendingException;

public class StepDefinition {

// We need copy the methods generated from the commandline.

}

Note: Remove the throw new PendingException(); line because we are not dealing with that.

5. Compile the StepDefinition.java file and enter the following command from the command              line then the .class file will be generated in the step_definition

           javac -cp “jars/*” step_definition/StepDefinition.java

6. Enter the below commands and run the file for getting result.

            java -cp “jars/*;.” cucumber.api.cli.Main -p pretty -g step_definition features/Test.feature9

If we want the result in json format then we have to give the command as

java -cp “jars/*;.” cucumber.api.cli.Main –plugin json -g step_definition features/Test.feature

Note: We can see the result in so many ways for that refer with the help of

 java -cp “jars/*;.” cucumber.api.cli.Main–help

At Qentelli, we have applied these principles in complex N-Tier architecture based applications to bring Continuous Delivery to our customers. The next steps in the sequence are ensuring Continuous Testing covers Continuous Security and Performance Engineering followed by Continuous Build, Deployments and Monitoring and Feedback. To learn more about Quality Driven Development, Continuous Delivery the Qentelli Way and DevOps reach out to us.

Comments are closed.