smart bdd testing using cucumber and jacoco

2
Smart BDD Testing Using Cucumber and JaCoCo Behavioral Driven Development (BDD) testing uses natural language to provide a description of the ‘desired behavior' of a system, which can be understood by developers, testers and the users. It is a synthesis and refinement of practices that stem from TDD and ATDD. The behaviors are described in a single notation and are made accessible to the experts in a particular domain, as well as to the developers and testers, to help in better communication. The behaviors that are involved in BDD testing are those that have a huge impact on the business-related outcomes of a particular system. . One can achieve BDD with an open source tool known as Cucumber, which parses the tests in Gherkin language. Problems faced in utilizing the BDD Testing Framework Difficult to justify the framework’s coverage due to code complexity Developers disagree on exposing source codes and APIs Massive efforts required to convert the software to the Gherkin language in the later stages of software development Lack of testers with adequate coding and technical knowledge Difficult to convince BTMs on the need for daily reviews of scenarios The way to the solution Conventionally, software requirements are written in a normal language and then later converted in Gherkin format. This requires additional effort and time. The solution to this problem is to write the requirements and other specifics in the Gherkin format right from the very beginning, which will help minimize both effort and cost. For example: Traditional software requirement: As a user, I want to login to the application with valid credentials. Simple Cucumber Feature File in the Gherkin format: Feature: Login to the system User should be allowed to login with valid credentials Scenario: Login success Given the login page is opened When I input a valid username and password in the textboxes and I click the login button Then, I have logged in successfully The usual method of application testing involves its API or web services. However, in scenarios where neither is available, it can cause obstacles in testing. This can be overcome by writing JUnit classes by the developers. The JUnit is an important unit testing framework which is used by Java programmers for test-driven development programs. The BDD approach uses Cucumber to leverage JUnit testing. JaCoCo is another tool that can be combined with Cucumber, to ensure that the testing covers all the areas of the application, as the scenarios or tests are behavior specific. Key benefits of BDD Testing Cucumber and JaCoCo are open-source tools providing the same benefits as other paid tools

Upload: akhil-agarwal

Post on 22-Jul-2016

215 views

Category:

Documents


0 download

DESCRIPTION

Behavioural Driven Development (BDD) testing uses natural language to describe the “desired behaviour” of the system that can be understood by the developer, tester and the customer. It is a synthesis and refinement of practices stemming from TDD and ATDD. This paper focuses on the problems faced in utilizing the BDD testing framework and the possible solutions.

TRANSCRIPT

Page 1: Smart bdd testing using cucumber and jacoco

Smart BDD Testing Using Cucumber and JaCoCo

Behavioral Driven Development (BDD) testing uses natural language to provide a description of the

‘desired behavior' of a system, which can be understood by developers, testers and the users. It is a

synthesis and refinement of practices that stem from TDD and ATDD. The behaviors are described in

a single notation and are made accessible to the experts in a particular domain, as well as to the

developers and testers, to help in better communication. The behaviors that are involved in BDD

testing are those that have a huge impact on the business-related outcomes of a particular system. .

One can achieve BDD with an open source tool known as Cucumber, which parses the tests in

Gherkin language.

Problems faced in utilizing the BDD Testing Framework

Difficult to justify the framework’s coverage due to code complexity

Developers disagree on exposing source codes and APIs

Massive efforts required to convert the software to the Gherkin language in the later stages

of software development

Lack of testers with adequate coding and technical knowledge

Difficult to convince BTMs on the need for daily reviews of scenarios

The way to the solution

Conventionally, software requirements are written in a normal language and then later converted in

Gherkin format. This requires additional effort and time. The solution to this problem is to write the

requirements and other specifics in the Gherkin format right from the very beginning, which will

help minimize both effort and cost. For example:

Traditional software requirement: As a user, I want to login to the application with valid credentials.

Simple Cucumber Feature File in the Gherkin format:

Feature: Login to the system User should be allowed to login with valid credentials Scenario: Login success Given the login page is opened When I input a valid username and password in the textboxes and I click the login button Then, I have logged in successfully The usual method of application testing involves its API or web services. However, in scenarios where neither is available, it can cause obstacles in testing. This can be overcome by writing JUnit classes by the developers. The JUnit is an important unit testing framework which is used by Java programmers for test-driven development programs. The BDD approach uses Cucumber to leverage JUnit testing. JaCoCo is another tool that can be combined with Cucumber, to ensure that the testing covers all the areas of the application, as the scenarios or tests are behavior specific. Key benefits of BDD Testing

Cucumber and JaCoCo are open-source tools providing the same benefits as other paid tools

Page 2: Smart bdd testing using cucumber and jacoco

Test execution time in functional testing can reduce by almost 80%

Cucumber can be integrated with existing tools like Selenium, TestComplete, and QTP

The quality of an application increases, as any defects are detected during the early stages of development

Cucumber can be used to test REST and SOAP Web services, showing its convenient adjusting abilities in traditional API automation

Projects to which the BDD testing approach can be applied

Any domain, as it is not limited to any particular one Traditional automation approaches API-based projects (by leveraging Cucumber) JUnit/NUnit test methods (used along with Cucumber to achieve BDD) Cucumber dependencies are openly available and allow for easy integration with any

project Some upcoming features

Real time editing shared globally 24/7 access to the latest version of executable specifications Link to issue trackers Edit incorrect specifications instantly and see the results as they appear

Reference: http://www.hcltech.com/systems-integration/specialized-testing-services-sts http://www.hcltech.com/white-papers/systems-integration/smart-bdd-testing-using-cucumber-and-jacoco