Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Mastering Behavior-Driven Development Using Cucumber: Practice and Implement Page Object Design Pattern, Test Suites in Cucumber, POM TestNG Integration, Cucumber Reports, and work with Selenium Grid
Mastering Behavior-Driven Development Using Cucumber: Practice and Implement Page Object Design Pattern, Test Suites in Cucumber, POM TestNG Integration, Cucumber Reports, and work with Selenium Grid
Mastering Behavior-Driven Development Using Cucumber: Practice and Implement Page Object Design Pattern, Test Suites in Cucumber, POM TestNG Integration, Cucumber Reports, and work with Selenium Grid
Ebook381 pages3 hours

Mastering Behavior-Driven Development Using Cucumber: Practice and Implement Page Object Design Pattern, Test Suites in Cucumber, POM TestNG Integration, Cucumber Reports, and work with Selenium Grid

Rating: 0 out of 5 stars

()

Read preview

About this ebook

In this book, readers will learn everything they need to know about Behavior-Driven Development (BDD) and a framework used for automation testing for BDD.
The book is divided into three sections. The first section covers the building blocks of Cucumber such as Feature files, Step Definition classes, and Runner classes, among other things. These will serve as the building blocks for becoming more familiar with Cucumber.

The second section covers the Page Object design pattern and Page Factories, both of which are useful in developing robust frameworks.

The final section demonstrates Cucumber's integration with TestNG and Maven. We will be putting each Maven build in Jenkins and configuring Jenkins to trigger automatically when a development build is completed.
After reading this book, the test engineer will understand the concept of incorporating Cucumber as a BDD framework into his testing. As a result, he will be able to streamline the testing and bug detection processes.
LanguageEnglish
Release dateSep 8, 2021
ISBN9789391030551
Mastering Behavior-Driven Development Using Cucumber: Practice and Implement Page Object Design Pattern, Test Suites in Cucumber, POM TestNG Integration, Cucumber Reports, and work with Selenium Grid

Related to Mastering Behavior-Driven Development Using Cucumber

Related ebooks

Internet & Web For You

View More

Related articles

Reviews for Mastering Behavior-Driven Development Using Cucumber

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Mastering Behavior-Driven Development Using Cucumber - Pinakin A Chaubal

    CHAPTER 1

    Introduction to Behavior Driven Development

    Welcome to the exciting world of Behavior Driven Development ( BDD ). This book will be divided into three parts. The first part will make the user understand what Cucumber is all about. The second part will explore the Page Object Model and Page Factories. The third part will cover integration of Cucumber with the TestNG framework. It is going to be a very exciting journey, so let’s get started and understand what BDD is all about.

    BDD helps to bridge the gap between business people and technical people by implementing a language called ‘Gherkin’. It consists of statements in English predominantly, although other languages are available for this purpose too. A group of Gherkin statements together lists a functional flow. These statements are taken by the Automation developer and converted into code using frameworks like Cucumber, JBehave or Specflow. BDD is quite frequently used in Agile projects for getting quick feedback on code quality after developers check in their code in source code management systems like GitHub or SVN. The BDD tests can be configured to execute immediately after the code is checked in.

    This chapter will predominantly focus on

    Test Driven Development

    Behavior Driven Development

    Understanding Gherkin

    Introduction to Cucumber

    Understanding the DRY principle

    Components of Cucumber

    Setup of the project in Eclipse

    Setup of TestNG in Eclipse

    Understanding the project structure

    Objective

    After reading this chapter, the reader will be conversant with the concepts of TDD, BDD, Gherkin and able to create a basic file called ‘Feature File’ in the Gherkin Language. He will also learn how the Gherkin file relates to the Step Definition file which is one of the components of Cucumber. He will get knowledge of the project structure and understand how to set up a project in Eclipse along with TestNG Plugin integration. This chapter will serve as the foundation for one who wishes to work as a Test Automation Engineer and wants to make a career in BDD framework.

    1.1 What is TDD?

    TDD stands for Test Driven Development. Test Driven Development is a software development process where test cases are written first taking into consideration the requirements in a traditional project or the user stories in a scrum or agile project. Once the tests are created, minimal code to make the tests pass is created. As and when new tests are created, the code is updated to make the new tests pass and at the same time ensuring that the existing tests pass as well.

    TDD (We will refer to this acronym for Test Driven Development going forward) was developed or rediscovered by Kent Beck in 2003 to facilitate simple designs. TDD is related to test first programming concepts of Extreme Programming.

    1.1.1 Steps involved in a TDD

    The steps mentioned below should be followed in a typical Test Driven Development approach.

    Write the test: This activity can be done by the tester or developer where a test is created from the user story, requirement or use case. This is contrasted to the traditional approach of writing unit tests after the code is written. TDD enables the developer to focus on the requirements (We will refer to user stories, traditional requirements or use cases as requirements going forward) before getting started with the code. This differentiated TDD from a traditional development approach.

    Run the test to check that it fails: Prepare the development system such that bare minimum code is there to make your application run like creating the main method or a screen with the required stubs for the database or web service for example. Since writing the test was the very first activity done, it should definitely fail since we don't have any code in place to support the test. If the test fails, then we are sure that the test has been written correctly.

    Write the development code: Now it's time to make our test pass by writing only the required code to make the test pass. It is strongly recommended not to write more code in this step. Writing more code results in what is called Gold Plating where you are just giving additional features that are not required at the present moment.

    Check to see that the test passes: Run our first test again and this time it should pass. This helps to ensure that all the correct development code is in place and we can move on to the next test.

    Refactor the code: In the iterative TDD process, we need to make sure that we have not introduced any duplication, all the design principles are met and the methods are where they are supposed to be, that is, logically grouped together in a

    Enjoying the preview?
    Page 1 of 1