SlideShare une entreprise Scribd logo
1  sur  45
Cucumber-JVM Best Practices
V3
Ahmed Misbah
Agenda
• Introduction
– Layers of Agile Development
– Test Driven Development
– Behavior Driven Development
• Cucumber-JVM
• Best Practices
Rules
• Phones silent
• No laptops
• Questions/Discussions at anytime welcome
• 10 minute break every 1 hour
INTRODUCTION
Layers of Agile Development
Agile Practices
• Pair Programming
• Test Driven Development
• Acceptance Test Driven Development
• Behavior Driven Development
• Specification by Example
• Collective Ownership
• Continuous Deployment
• Continuous Integration
• Version Control
• Definition of Ready
• Definition of Done
Test Driven Development
• Test-Driven Development (TDD) is a software
development process that relies on the
repetition of a very short development cycle
• Requirements are turned into very specific
test cases, then the software is improved to
pass the new tests only
• Kent Beck is credited with having developed
or 'rediscovered’ the technique
TDD and XP
• Testing in XP:
– All code must have unit tests
– All code must pass all unit tests before it can be
released.
– When a bug is found tests are created before the
bug is addressed (a bug is not an error in logic, it is
a test that was not written)
– Acceptance tests are run often and the results are
published
How do we do TDD?
Behavior Driven Development (1/2)
• Behavior-Driven Development (BDD) is a
software development process that emerged
from Test-Driven development (TDD)
• It combines the general techniques and principles
of TDD with ideas from domain-driven design
and object-oriented analysis and design to
provide software development and management
teams with shared tools and a shared process to
collaborate on software development
Behavior Driven Development (2/2)
• BDD is largely facilitated through the use of a
simple domain-specific language (DSL) using
natural language constructs (e.g., English-like
sentences) that can express the behavior and
the expected outcomes
• DSL can be written as Test Scripts and
converted into Fixtures for automating tests
Behavioral Specifications
• Title: The story should have a clear, explicit title: Narrative
A short, introductory section that specifies:
– who (which business or project role) is the driver or primary
stakeholder of the story (the actor who derives business benefit
from the story)
– what effect the stakeholder wants the story to have
– what business value the stakeholder will derive from this effect
• Acceptance criteria or scenarios: a description of each
specific case of the narrative. Such a scenario has the
following structure:
– It starts by specifying the initial condition that is assumed to be
true at the beginning of the scenario. This may consist of a
single clause, or several
– It then states which event triggers the start of the scenario
– Finally, it states the expected outcome, in one or more clauses
User Stories
• Written in the following notation:
– As who
– I want what
– So that why
• A User Story has three components (3Cs):
o Card
o Conversation
o Confirmation
An example of a User Story
Acceptance Criteria/Scenarios
• Scenarios are described in Given [initial
context] When [event occurs] Then [ensures
some outcome] notation
Problem Domain vs. Solution Domain
Problem Domain Solution Domain
Implement
Validate
BDD Frameworks and Libraries
• Cucumber (Java and Ruby)
• JBehave (Java)
• Behat (PHP)
• Jasmine (JS)
CUCUMBER-JVM
Cucumber
• Cucumber is a software tool that computer
programmers use for testing other software
• It runs automated acceptance tests written in
a behavior-driven development (BDD) style
• Gherkin is the language that Cucumber uses
to define test cases
Gherkin
• Gherkin is designed to be non-technical and
human readable, and collectively describes use
cases relating to a software system
• It seeks to enforce firm, unambiguous
requirements starting in the initial phases of
requirements definition by business management
and in other stages of the development lifecycle
• In addition to providing a script for automated
testing, Gherkin's natural language syntax is
designed to provide simple documentation of the
code under test
Cucumber/Gherkin Syntax
• All Gherkin files have the .feature file
extension. They contain a single Feature
definition for the system under test and are an
executable test script
• Cucumber tests are divided into individual
Features. These Features are subdivided into
Scenarios, which are sequences of Steps
Feature Definition
Scenarios
Scenarios and Examples
Steps (1/2)
• Given - Describes the preconditions and initial
state before the start of a test and allows for any
pre-test setup that may occur
• When - Describes actions taken by a user during a
test
• Then - Describes the outcome resulting from
actions taken in the When clause
• And - Logical and
• But - Logically the same as And, but used in the
negative form
Steps (2/2)
Tags (1/2)
• Gherkin's Feature structure forces organization.
However, in cases where this default organization
is inconvenient or insufficient, Gherkin provides
Tags
• Tags are @-prefixed strings and can be placed
before:
– Feature
– Scenario
– Scenario Outline
– Examples
Tags (2/2)
@SetupTestData
Cucumber-JVM
• Cucumber-JVM is a pure Java implementation
of Cucumber
• Cucumber-JVM also integrates with all the
popular Dependency Injection containers (e.g.
Spring)
Cucumber-JVM code
Hooks
• Hooks are Cucumber's way of allowing for setup to be
performed prior to tests being run and teardown to be
run afterwards
• Three basic types of hooks exist:
– Before - Runs before a scenario
– After - Runs after a scenario
– Around - Assumes control and runs around a scenario
• Additional hooks include:
– BeforeStep
– AfterStep
– AfterConfiguration - Runs after Cucumber configuration
and is passed an instance of the configuration
BEST PRACTICES
Feature file writing
• Feature files should be written using one of the
following approaches:
– Specification workshops - when starting out, having the
whole team attend specification workshops acts as a
useful introduction to the approach. Over time, some
teams decide to continue with a whole-team approach,
while others reduce the number of people in each session.
– 3 Amigos - suggests a minimum of 3 functional roles;
developer(s), tester(s) and business analyst or product
owner.
– Example mapping - uses index cards as a means to engage
all team members collaboratively and visually map the
story, acceptance criteria or rules, and examples.
Code Coverage
• Code Coverage should not rely entirely on
Feature Files
• Feature files should cover Acceptance Tests
• Most code coverage should come from Unit
Tests
Feature Files Writing Guidelines
1. All scenarios must be independent and deterministic.
This means that the scenario should run alone
successfully without depending on other feature files
or scenarios to run before it
2. Use DRY concept in writing Cucumber/Gherkin
feature files. This means that step definitions should
be written in a form that will make them reusable and
easy to refactor
3. Use Scenario Outlines. This implies writing single
scenarios for testing multiple data and relying on
examples to describe test data and verify different
outcomes
Feature Files Writing Guidelines
(cont’d)
4. Use regular expressions in Step Definitions for
ignoring plurals to promote reusability
particularly in setting up test data
Given the following user exists
| Username | Role |
| msaeed | Budget_Manager |
Given the following users exist
| Username | Role |
| msaeed | Budget_Manager |
| msaeed | Budget_Manager |
@Given("^the following users? exists?$")
public void the_following_user_exists(List<UserTestCommand>
userList) throws Throwable{
}
Feature Files Writing Guidelines
(cont’d)
5. Use tables in feature files for writing “When”
steps
Bad Practice
Feature Files Writing Guidelines
(cont’d)
Good Practice
Feature Files Writing Guidelines
(cont’d)
6. Setting up test data will be using:
– Tags (SQL scripts for global data - Separate tag for
each entity - Tag for all data - Use flyway migration
scripts)
– Background (for feature specific data)
– Given (for scenario specific data)
7. Truncate all tables from one scenario to the
other and run SQL migrations
Feature Files Writing Guidelines
(cont’d)
8. One step definition per API command for
setting up test data
9. Use business identifiers in feature file test
data
Building Test Data in Step Definitions
• Test data defined in Cucumber/Gherkin
feature files should be persisted using Builders
that will call the actual production APIs. The
Builders will construct the API Commands that
will be used to call the REST APIs
Building Test Data in Step Definitions
• Cucumber only injects objects that are declared
in the Step Definition class currently being run. To
overcome this problem, Cucumber glues are
declared in Spring Context XML to allow the glue
class to be injected in all classes that run
• Injecting all builders into a single class (or factory)
and declare this class as Cucumber Glue. Any
class that will use a builder will retrieve the
builder from the Builder Factory
Thank You!

Contenu connexe

Tendances

PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...Puppet
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOpsEklove Mohan
 
Roadmap to Enterprise Quality
Roadmap to Enterprise QualityRoadmap to Enterprise Quality
Roadmap to Enterprise QualityJeff Bramwell
 
Preparing for DevOps
Preparing for DevOpsPreparing for DevOps
Preparing for DevOpsEklove Mohan
 
What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...
What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...
What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...Edureka!
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICDKnoldus Inc.
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsDicodingEvent
 
DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...
DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...
DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...DevSecCon
 
Common blind spots on the journey to production vijay raghavan aravamudhan
Common blind spots on the journey to production  vijay raghavan aravamudhanCommon blind spots on the journey to production  vijay raghavan aravamudhan
Common blind spots on the journey to production vijay raghavan aravamudhanXP Conference India
 
Take your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to ModernizationTake your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to ModernizationOrtus Solutions, Corp
 
Continuous Delivery Distilled
Continuous Delivery DistilledContinuous Delivery Distilled
Continuous Delivery DistilledMatt Callanan
 
Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...
Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...
Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...Taller Negócio Digitais
 
Modern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsModern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsGlobalLogic Ukraine
 
What's an SRE at Criteo - Meetup SRE Paris
What's an SRE at Criteo - Meetup SRE ParisWhat's an SRE at Criteo - Meetup SRE Paris
What's an SRE at Criteo - Meetup SRE ParisClément Michaud
 
DevOps - Continuous Integration, Continuous Delivery - let's talk
DevOps - Continuous Integration, Continuous Delivery - let's talkDevOps - Continuous Integration, Continuous Delivery - let's talk
DevOps - Continuous Integration, Continuous Delivery - let's talkD Z
 
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...Puppet
 

Tendances (20)

PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
PuppetConf 2016: Successful Puppet Implementation in Large Organizations – Ja...
 
Getting to Walk with DevOps
Getting to Walk with DevOpsGetting to Walk with DevOps
Getting to Walk with DevOps
 
Roadmap to Enterprise Quality
Roadmap to Enterprise QualityRoadmap to Enterprise Quality
Roadmap to Enterprise Quality
 
Preparing for DevOps
Preparing for DevOpsPreparing for DevOps
Preparing for DevOps
 
From Continuous Integration to DevOps
From Continuous Integration to DevOpsFrom Continuous Integration to DevOps
From Continuous Integration to DevOps
 
Better java with design
Better java with designBetter java with design
Better java with design
 
What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...
What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...
What is Continuous Integration? | Continuous Integration with Jenkins | DevOp...
 
Introduction to CICD
Introduction to CICDIntroduction to CICD
Introduction to CICD
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
 
DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...
DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...
DevSecCon London 2017: Permitting agility whilst enforcing security by Alina ...
 
Common blind spots on the journey to production vijay raghavan aravamudhan
Common blind spots on the journey to production  vijay raghavan aravamudhanCommon blind spots on the journey to production  vijay raghavan aravamudhan
Common blind spots on the journey to production vijay raghavan aravamudhan
 
Take your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to ModernizationTake your CFML Legacy Apps to Modernization
Take your CFML Legacy Apps to Modernization
 
Continuous Delivery Distilled
Continuous Delivery DistilledContinuous Delivery Distilled
Continuous Delivery Distilled
 
Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...
Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...
Best practices for Continuous Deployment with Drupal - DrupalCon Latin Améric...
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 
Modern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOpsModern CI/CD Pipeline Using Azure DevOps
Modern CI/CD Pipeline Using Azure DevOps
 
What's an SRE at Criteo - Meetup SRE Paris
What's an SRE at Criteo - Meetup SRE ParisWhat's an SRE at Criteo - Meetup SRE Paris
What's an SRE at Criteo - Meetup SRE Paris
 
Azure DevOps
Azure DevOpsAzure DevOps
Azure DevOps
 
DevOps - Continuous Integration, Continuous Delivery - let's talk
DevOps - Continuous Integration, Continuous Delivery - let's talkDevOps - Continuous Integration, Continuous Delivery - let's talk
DevOps - Continuous Integration, Continuous Delivery - let's talk
 
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
 

Similaire à Cucumber jvm best practices v3

Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to useUma Ghotikar
 
Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008Pete Schneider
 
Testing Frameworks
Testing FrameworksTesting Frameworks
Testing FrameworksMoataz Nabil
 
Automated testing overview
Automated testing overviewAutomated testing overview
Automated testing overviewAlex Pop
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsSteven Li
 
Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012
Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012
Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012TEST Huddle
 
How To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationHow To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationRanorex
 
Testing strategy for agile projects updated
Testing strategy for agile projects updatedTesting strategy for agile projects updated
Testing strategy for agile projects updatedTharinda Liyanage
 
Cloud-based Test Microservices JavaOne 2014
Cloud-based Test Microservices JavaOne 2014Cloud-based Test Microservices JavaOne 2014
Cloud-based Test Microservices JavaOne 2014Shelley Lambert
 
Performance tesing coding standards & best practice guidelines v1
Performance tesing coding standards & best practice guidelines v1Performance tesing coding standards & best practice guidelines v1
Performance tesing coding standards & best practice guidelines v1Argos
 
Lecture3.se.pptx
Lecture3.se.pptxLecture3.se.pptx
Lecture3.se.pptxAmna Ch
 
Test Case Management with MTM 2013
Test Case Management with MTM 2013Test Case Management with MTM 2013
Test Case Management with MTM 2013Raluca Suditu
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Ortus Solutions, Corp
 
SWT2_tim.pptx
SWT2_tim.pptxSWT2_tim.pptx
SWT2_tim.pptxBnhT27
 

Similaire à Cucumber jvm best practices v3 (20)

Testing - How Vital and How Easy to use
Testing - How Vital and How Easy to useTesting - How Vital and How Easy to use
Testing - How Vital and How Easy to use
 
Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008Context Driven Automation Gtac 2008
Context Driven Automation Gtac 2008
 
Testing Frameworks
Testing FrameworksTesting Frameworks
Testing Frameworks
 
Automated testing overview
Automated testing overviewAutomated testing overview
Automated testing overview
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementations
 
Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012
Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012
Fran O'Hara - Evolving Agile Testing - EuroSTAR 2012
 
Qa documentation pp
Qa documentation ppQa documentation pp
Qa documentation pp
 
How To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test AutomationHow To Transform the Manual Testing Process to Incorporate Test Automation
How To Transform the Manual Testing Process to Incorporate Test Automation
 
Testing strategy for agile projects updated
Testing strategy for agile projects updatedTesting strategy for agile projects updated
Testing strategy for agile projects updated
 
Gherkin model BDD
Gherkin model BDDGherkin model BDD
Gherkin model BDD
 
Cloud-based Test Microservices JavaOne 2014
Cloud-based Test Microservices JavaOne 2014Cloud-based Test Microservices JavaOne 2014
Cloud-based Test Microservices JavaOne 2014
 
Gherkin model1
Gherkin model1Gherkin model1
Gherkin model1
 
Software automation
Software automationSoftware automation
Software automation
 
Performance tesing coding standards & best practice guidelines v1
Performance tesing coding standards & best practice guidelines v1Performance tesing coding standards & best practice guidelines v1
Performance tesing coding standards & best practice guidelines v1
 
Lecture3.se.pptx
Lecture3.se.pptxLecture3.se.pptx
Lecture3.se.pptx
 
Test Case Management with MTM 2013
Test Case Management with MTM 2013Test Case Management with MTM 2013
Test Case Management with MTM 2013
 
Gcs day1
Gcs day1Gcs day1
Gcs day1
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
SWT2_tim.pptx
SWT2_tim.pptxSWT2_tim.pptx
SWT2_tim.pptx
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

Plus de Ahmed Misbah

6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)Ahmed Misbah
 
Migrating to Microservices Patterns and Technologies (edition 2023)
 Migrating to Microservices Patterns and Technologies (edition 2023) Migrating to Microservices Patterns and Technologies (edition 2023)
Migrating to Microservices Patterns and Technologies (edition 2023)Ahmed Misbah
 
Practical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfPractical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfAhmed Misbah
 
Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Ahmed Misbah
 
DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)Ahmed Misbah
 
TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)Ahmed Misbah
 
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Ahmed Misbah
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDDAhmed Misbah
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioAhmed Misbah
 
Welcome to the Professional World
Welcome to the Professional WorldWelcome to the Professional World
Welcome to the Professional WorldAhmed Misbah
 
More topics on Java
More topics on JavaMore topics on Java
More topics on JavaAhmed Misbah
 
Career Paths for Software Professionals
Career Paths for Software ProfessionalsCareer Paths for Software Professionals
Career Paths for Software ProfessionalsAhmed Misbah
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story WritingAhmed Misbah
 
DDT Testing Library for Android
DDT Testing Library for AndroidDDT Testing Library for Android
DDT Testing Library for AndroidAhmed Misbah
 
Software Architecture
Software ArchitectureSoftware Architecture
Software ArchitectureAhmed Misbah
 
How Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous DeliveryHow Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous DeliveryAhmed Misbah
 
Agile Software Development and DevOps 21092019
Agile Software Development and DevOps 21092019Agile Software Development and DevOps 21092019
Agile Software Development and DevOps 21092019Ahmed Misbah
 

Plus de Ahmed Misbah (20)

6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)6+1 Technical Tips for Tech Startups (2023 Edition)
6+1 Technical Tips for Tech Startups (2023 Edition)
 
Migrating to Microservices Patterns and Technologies (edition 2023)
 Migrating to Microservices Patterns and Technologies (edition 2023) Migrating to Microservices Patterns and Technologies (edition 2023)
Migrating to Microservices Patterns and Technologies (edition 2023)
 
Practical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdfPractical Microservice Architecture (edition 2022).pdf
Practical Microservice Architecture (edition 2022).pdf
 
Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)Istio as an enabler for migrating to microservices (edition 2022)
Istio as an enabler for migrating to microservices (edition 2022)
 
DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)DevOps for absolute beginners (2022 edition)
DevOps for absolute beginners (2022 edition)
 
TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)TDD Anti-patterns (2022 edition)
TDD Anti-patterns (2022 edition)
 
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
Istio as an Enabler for Migrating Monolithic Applications to Microservices v1.3
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
Microservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and IstioMicroservice test strategies for applications based on Spring, K8s and Istio
Microservice test strategies for applications based on Spring, K8s and Istio
 
Welcome to the Professional World
Welcome to the Professional WorldWelcome to the Professional World
Welcome to the Professional World
 
More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
Career Paths for Software Professionals
Career Paths for Software ProfessionalsCareer Paths for Software Professionals
Career Paths for Software Professionals
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story Writing
 
AndGen+
AndGen+AndGen+
AndGen+
 
DDT Testing Library for Android
DDT Testing Library for AndroidDDT Testing Library for Android
DDT Testing Library for Android
 
Big Data for QAs
Big Data for QAsBig Data for QAs
Big Data for QAs
 
Software Architecture
Software ArchitectureSoftware Architecture
Software Architecture
 
Software Design
Software DesignSoftware Design
Software Design
 
How Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous DeliveryHow Spinnaker helped us achieve real Continuous Delivery
How Spinnaker helped us achieve real Continuous Delivery
 
Agile Software Development and DevOps 21092019
Agile Software Development and DevOps 21092019Agile Software Development and DevOps 21092019
Agile Software Development and DevOps 21092019
 

Dernier

%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 

Dernier (20)

%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 

Cucumber jvm best practices v3

  • 2. Agenda • Introduction – Layers of Agile Development – Test Driven Development – Behavior Driven Development • Cucumber-JVM • Best Practices
  • 3. Rules • Phones silent • No laptops • Questions/Discussions at anytime welcome • 10 minute break every 1 hour
  • 5. Layers of Agile Development
  • 6. Agile Practices • Pair Programming • Test Driven Development • Acceptance Test Driven Development • Behavior Driven Development • Specification by Example • Collective Ownership • Continuous Deployment • Continuous Integration • Version Control • Definition of Ready • Definition of Done
  • 7. Test Driven Development • Test-Driven Development (TDD) is a software development process that relies on the repetition of a very short development cycle • Requirements are turned into very specific test cases, then the software is improved to pass the new tests only • Kent Beck is credited with having developed or 'rediscovered’ the technique
  • 8. TDD and XP • Testing in XP: – All code must have unit tests – All code must pass all unit tests before it can be released. – When a bug is found tests are created before the bug is addressed (a bug is not an error in logic, it is a test that was not written) – Acceptance tests are run often and the results are published
  • 9.
  • 10. How do we do TDD?
  • 11. Behavior Driven Development (1/2) • Behavior-Driven Development (BDD) is a software development process that emerged from Test-Driven development (TDD) • It combines the general techniques and principles of TDD with ideas from domain-driven design and object-oriented analysis and design to provide software development and management teams with shared tools and a shared process to collaborate on software development
  • 12. Behavior Driven Development (2/2) • BDD is largely facilitated through the use of a simple domain-specific language (DSL) using natural language constructs (e.g., English-like sentences) that can express the behavior and the expected outcomes • DSL can be written as Test Scripts and converted into Fixtures for automating tests
  • 13. Behavioral Specifications • Title: The story should have a clear, explicit title: Narrative A short, introductory section that specifies: – who (which business or project role) is the driver or primary stakeholder of the story (the actor who derives business benefit from the story) – what effect the stakeholder wants the story to have – what business value the stakeholder will derive from this effect • Acceptance criteria or scenarios: a description of each specific case of the narrative. Such a scenario has the following structure: – It starts by specifying the initial condition that is assumed to be true at the beginning of the scenario. This may consist of a single clause, or several – It then states which event triggers the start of the scenario – Finally, it states the expected outcome, in one or more clauses
  • 14. User Stories • Written in the following notation: – As who – I want what – So that why • A User Story has three components (3Cs): o Card o Conversation o Confirmation
  • 15. An example of a User Story
  • 16. Acceptance Criteria/Scenarios • Scenarios are described in Given [initial context] When [event occurs] Then [ensures some outcome] notation
  • 17.
  • 18. Problem Domain vs. Solution Domain Problem Domain Solution Domain Implement Validate
  • 19. BDD Frameworks and Libraries • Cucumber (Java and Ruby) • JBehave (Java) • Behat (PHP) • Jasmine (JS)
  • 21. Cucumber • Cucumber is a software tool that computer programmers use for testing other software • It runs automated acceptance tests written in a behavior-driven development (BDD) style • Gherkin is the language that Cucumber uses to define test cases
  • 22. Gherkin • Gherkin is designed to be non-technical and human readable, and collectively describes use cases relating to a software system • It seeks to enforce firm, unambiguous requirements starting in the initial phases of requirements definition by business management and in other stages of the development lifecycle • In addition to providing a script for automated testing, Gherkin's natural language syntax is designed to provide simple documentation of the code under test
  • 23. Cucumber/Gherkin Syntax • All Gherkin files have the .feature file extension. They contain a single Feature definition for the system under test and are an executable test script • Cucumber tests are divided into individual Features. These Features are subdivided into Scenarios, which are sequences of Steps
  • 27. Steps (1/2) • Given - Describes the preconditions and initial state before the start of a test and allows for any pre-test setup that may occur • When - Describes actions taken by a user during a test • Then - Describes the outcome resulting from actions taken in the When clause • And - Logical and • But - Logically the same as And, but used in the negative form
  • 29. Tags (1/2) • Gherkin's Feature structure forces organization. However, in cases where this default organization is inconvenient or insufficient, Gherkin provides Tags • Tags are @-prefixed strings and can be placed before: – Feature – Scenario – Scenario Outline – Examples
  • 31. Cucumber-JVM • Cucumber-JVM is a pure Java implementation of Cucumber • Cucumber-JVM also integrates with all the popular Dependency Injection containers (e.g. Spring)
  • 33. Hooks • Hooks are Cucumber's way of allowing for setup to be performed prior to tests being run and teardown to be run afterwards • Three basic types of hooks exist: – Before - Runs before a scenario – After - Runs after a scenario – Around - Assumes control and runs around a scenario • Additional hooks include: – BeforeStep – AfterStep – AfterConfiguration - Runs after Cucumber configuration and is passed an instance of the configuration
  • 35. Feature file writing • Feature files should be written using one of the following approaches: – Specification workshops - when starting out, having the whole team attend specification workshops acts as a useful introduction to the approach. Over time, some teams decide to continue with a whole-team approach, while others reduce the number of people in each session. – 3 Amigos - suggests a minimum of 3 functional roles; developer(s), tester(s) and business analyst or product owner. – Example mapping - uses index cards as a means to engage all team members collaboratively and visually map the story, acceptance criteria or rules, and examples.
  • 36. Code Coverage • Code Coverage should not rely entirely on Feature Files • Feature files should cover Acceptance Tests • Most code coverage should come from Unit Tests
  • 37. Feature Files Writing Guidelines 1. All scenarios must be independent and deterministic. This means that the scenario should run alone successfully without depending on other feature files or scenarios to run before it 2. Use DRY concept in writing Cucumber/Gherkin feature files. This means that step definitions should be written in a form that will make them reusable and easy to refactor 3. Use Scenario Outlines. This implies writing single scenarios for testing multiple data and relying on examples to describe test data and verify different outcomes
  • 38. Feature Files Writing Guidelines (cont’d) 4. Use regular expressions in Step Definitions for ignoring plurals to promote reusability particularly in setting up test data Given the following user exists | Username | Role | | msaeed | Budget_Manager | Given the following users exist | Username | Role | | msaeed | Budget_Manager | | msaeed | Budget_Manager | @Given("^the following users? exists?$") public void the_following_user_exists(List<UserTestCommand> userList) throws Throwable{ }
  • 39. Feature Files Writing Guidelines (cont’d) 5. Use tables in feature files for writing “When” steps Bad Practice
  • 40. Feature Files Writing Guidelines (cont’d) Good Practice
  • 41. Feature Files Writing Guidelines (cont’d) 6. Setting up test data will be using: – Tags (SQL scripts for global data - Separate tag for each entity - Tag for all data - Use flyway migration scripts) – Background (for feature specific data) – Given (for scenario specific data) 7. Truncate all tables from one scenario to the other and run SQL migrations
  • 42. Feature Files Writing Guidelines (cont’d) 8. One step definition per API command for setting up test data 9. Use business identifiers in feature file test data
  • 43. Building Test Data in Step Definitions • Test data defined in Cucumber/Gherkin feature files should be persisted using Builders that will call the actual production APIs. The Builders will construct the API Commands that will be used to call the REST APIs
  • 44. Building Test Data in Step Definitions • Cucumber only injects objects that are declared in the Step Definition class currently being run. To overcome this problem, Cucumber glues are declared in Spring Context XML to allow the glue class to be injected in all classes that run • Injecting all builders into a single class (or factory) and declare this class as Cucumber Glue. Any class that will use a builder will retrieve the builder from the Builder Factory