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
- English
- ePUB (mobile friendly)
- Available on iOS & Android
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
About This Book
Master the skills required to effectively use Cucumber BDD which simplifies Agile development and fast-paced time-to-market
Key Features
? A step-by-step explanation of each component of the Cucumber framework.
? Expert coverage on speeding up the implementation of the Cucumber framework.
? Includes Parallel Execution, Cloud Testing, Explore Gherkin, and many more.
Description
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.
What you will learn
? Understand the fundamentals of Test-Driven Development and Behavior-Driven Development.
? Investigate Cucumber's building blocks such as Feature Files and Step Definition Files.
? Learn the Base Class and inheritance concept within the Page Object Model Framework.
? Create a TestNG XML that calls the test runner class.
Who this book is for
This book is aimed at individuals who have a firm grasp of the fundamentals of Java and are interested in improving their knowledge of the BDD framework.
Table of Contents
Section 1: Understanding the Cucumber framework
Chapter 1: Introduction to Behavior-Driven Development
Chapter 2: Understanding Feature Files
Chapter 3: Understanding Step Definition files
Chapter 4: Learning about the TestRunner Section 2: Learning the Page Object Design Pattern
Chapter 5: Understanding the Page Object Model and Creating Page Objects
Chapter 6: Understanding Page Factories and Creating Page Factories Section 3: Integration with TestNG, Maven, and Jenkins
Chapter 7: Configuring the TestNG Framework
Chapter 8: Configuring Maven and Learning about POM.xml
Chapter 9: POM.xml Execution from Eclipse and Command Line
Chapter 10: Configuring POM.xml to Trigger TestNG xml
Chapter 11: Configuring the Runner Class for Cucumber Reporter Plugin
Chapter 12: Reporting Using Extent Reports
Chapter 13: Parallel Execution Using Selenium Grid
Chapter 14: Integration with Jenkins
About the Authors
Pinakin Chaubal is a BE (Computer Science) with 19+ years of experience in the IT area. He has done PMP, ISTQB, HP0-M47 (QTP 11.0 Functional testing expert), and INS-21(General Insurance). He is working as an Automation Architect at Intellect Design Arena Ltd. (Previously, Polaris Consulting). Previously, he worked with companies like Patni, Accenture, ACS International (USA), L&T Infotech (USA & India), Polaris Financial Technology, and SQS. He carries 6 years of onsite experience in the US and 8 months in Hong Kong and China working closely with the client and getting involved in senior management and stakeholder meetings. The clients that he has worked for are YES Bank, HSBC, Travelers Insurance, Harleysville Insurance, Albertsons retail chain, Bellsouth Telecommunications GE-Fleet Services, and GE-Supply. LinkedIn Profile: https://www.linkedin.com/in/pinakin-chaubal-300b372/
Blog Link: //www.youtube.com/channel/UCkkh8bX1KS5iaORXX23P8ZA
Frequently asked questions
Information
CHAPTER 1
Introduction to Behavior Driven Development
- 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
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?
1.1.1 Steps involved in a TDD
- 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 class.
- Repeat with new tests: Next we write new tests for new requirements and repeat steps 1-5 to ensure that the correct code is written and only the required code is written. TDD will help you build a near defect free application using the minimum amount of code. There are many tools in the market for TDD one of them being JUnit. Since this book is focussed on BDD, we won’t go into details about testing with JUnit.
1.2 What is BDD?
- Where to start
- What to test and what to exclude
- How much to test
- What to name the tests
- Understanding why a test fails
- Context: This defines the starting state Figure 1.1: Example of Given keyword
- Event: This defines the user's action or actions Figure 1.2: Example of When keyword
- Outcomes: This defines the expected results Figure 1.3: Example of ‘Then’ and ‘And’ keywords
- Given: The purpose of Given is to put the system in a known state before the user starts interacting with the system.
- When: The purpose of When steps is to describe the key action the user performs.
- Then: The purpose of Then steps is to observe outcomes. The observations should be related in some way to the business value in your feature description. The observations should also be on some kind of output – that is values that come out of the system.
- And: Used to connect multiple Given, When and Then steps.
1.3 What is Cucumber?
Table of contents
- Cover Page
- Title Page
- Copyright Page
- Dedication Page
- About the Author
- About the Reviewers
- Acknowledgement
- Preface
- Errata
- Table of Contents
- 1. Introduction to Behavior Driven Development
- 2. Understanding Feature Files
- 3. Step Definitions
- 4. Learning About the Test Runner
- 5. The Page Object Model Without Page Factory
- 6. Learning About the Page Object Model Using Page Factory
- 7. Configuring the TestNG Framework
- 8. Configuring Maven and Learning About POM.xml
- 9. Test Execution with Maven and Log4J
- 10. Configuring POM.XML to Trigger TestNG.XML
- 11. Configuring the Runner Class for the Cucumber Reporter Plugin
- 12. Reporting Using Extent Reports
- 13. Parallel Execution Using Selenium Grid
- 14. Integration with Jenkins
- Index