SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Boston Java Meetup, 13/06/2013
Test Automation
with Cucumber-JVM
Alan Parkinson
@alan_parkinson
Cucumber is a tool that executes plain-text
functional descriptions as automated tests
• Tests written in business-facing text
 Supports over 40 spoken languages
 This test is called Gherkin
• Automation written in target language
 Ruby, Java, Scala, Groovy, etc.. .net, python, PHP
Behaviour Driven
Development
• Program does not do what it is intended
• Fixed in development/QA
• Program does what is intended
• Unstated, misunderstood or tacit
requirements
IMPLEMENTATION DEFECT
REQUIREMENTS DEFECT
Software - What can go wrong?
A woman asks her husband, a
programmer, to go shopping.
She tells him “please, go to the nearby
grocery store to buy some bread. Also, if
they have eggs, buy 6”
50-60%of issues identified by testers can be chalked down as
Requirements Defects
100-200%more expensive to fix than other defects because
the code is already written
How does BDD help?
• All stakeholders involved in the discussion drives out clear and concise
specifications centred around business value.
• Write specifications in natural language so everyone is on the same page
• Turn the specification into acceptance tests that guarantees the software does
as it is intended
• Use those tests as the software evolves to guarantee that it continues to work
as intended.
• Specifications are documentation – each scenario describes how the system is
being used
Cucumber, The Origins
• Cucumber
 Ruby
 Born 2007-2008
• Cuke4Duke
 First seen in 2008
 JRuby
• Cucumber-JVM
 Released April 2012
 Java, Groovy, Clojure, Scala, Ioke, Jython, Rhino (JavaScript) and JRuby
Maven Dependencies
cucumber-
java
cucumber-
junit
cucumber-
picocontainer
cucumber-
guice
cucumber-
spring
Maven Dependencies
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
Scenarios - Given When Then
Given an owner with a registered pet called “Sly“
When the owner registers a new pet called “Sly“
Then the user should be warned that the pet already
exists
Writing Scenario's in Cucumber
• Scenarios are organized together into features
• Each feature is represented as a plain text file.
• Feature files must have the “.feature” extension
• Each feature can contain many scenarios
JUnit Runner
import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
public class RunnerIT {
}
JUnit Runner 2
• Body of the class should be empty
 No @Test annotated methods
 No @Before or @After methods
• Arguments can be provided with an additional
annotation
JUnit Runner - Arguments
@RunWith(Cucumber.class)
@Cucumber.Options(
features = "src/test/resources/features“
)
public class RunnerIT {
}
Step Definitions
• A single Method representing a Step from a Feature file
• The Method is annotated with information about the step it
represents
• Cucumber generates “Code Snippet's” for Step Definition it
can’t find
Step Annotations
import cucumber.annotation.en.*;
Each Gherkin step keyword has a Annotation
@When("^we want to stop traffic$")
public void methodName() { … }
Passing and Failing
• Each step has it own result state
 Passed
 Pending
 Skipped
 Failed
• Individual step result state combined determine the
Scenarios success or failure
• Steps can be failed on exceptions or JUnit Assertion failures
Regex Lesson
Cucumber uses Regular Expressions to match steps to
definitions.
@When("^we want to stop traffic$")
^ Matches the starting position
$ Matches the ending position
Capturing Arguments
@Given("^an owner with a pet called "Sly"$")
public void an_owner_with_a_pet_called() {
…
}
@Given("^an owner with a pet called "([^"]*)"$")
public void an_owner_with_a_pet_called(String name) {
…
}
Capturing Arguments 2
• The pair of brackets is a capture group
• Everything captured is passed to method parameter
• Cucumber will automatically convert to the method
parameter type
• Equal number of method parameters and capture groups
Type Conversion
• If the captured string is not in the correct format for type
conversion an error will be thrown
• Use regular expressions to capture the correct format string
for the type
Note: Escape regular expression characters with backslash
Typical Capture Groups
(.+) Good for capturing strings and dates
"([^"]*)" Captures a string within Double quotes
(d) Capture decimal numbers only
(d+.d+) Capture floating point numbers
(true|false) Captures a Boolean value
Date Formats
@Given ("^today is (.+)$")
public void today_is(Date date) {
….
}
Dates are recognized if it’s a format from the DateFormat class
Date Formats
SHORT is completely numeric, such as 12.13.52 or 3:30pm
MEDIUM is longer, such as Jan 12, 1952
LONG is longer, such as January 12, 1952 or 3:30:32pm
FULL is pretty completely specified, such as Tuesday, April 12,
1952 AD or 3:30:42pm PST.
Date Formats
import cucumber.DateFormat;
@Given ("^today is (.+)$")
public void today_is(
@DateFormat ("yyyy-MM-dd") Date date) {
….
}
Tag use cases
• Grouping Scenarios together
 Identify slow running test that shouldn’t be run frequently
 Identify tests that require a particular library or server
Running Scenarios with a Tag
@Cucumber.Options(
tags = {“@WebDriver”}, … )
Running Scenarios without a Tag
Cucumber can exclude Scenarios with a particular tag by
inserting the tilde character before the tag
For the following command will run all Scenarios without the
WebDriver tag
@Cucumber.Options(
tags = {“~@WebDriver”}, … )
Tag expressions – Logical OR
Separate a list of tags by commas for a Logical OR tag
expression
@Cucumber.Options(
tags = {“@WebDriver,@email”}, … )
Tag expressions – Logical AND
Specifying multiple tag arguments creates a logical AND
between each tag expression.
@Cucumber.Options(
tags = {“@WebDriver”, ”@email”}, … )
Tag expressions – AND OR
Run scenarios that are tagged with @WebDriver or @email
but not @slow
@Cucumber.Options(
tags = {“@WebDriver,@email”, “~@slow”}, … )
Further information
Official website: cukes.info
Github: github.com/cucumber/cucumber-jvm
Hindsight Software: hindsighttesting.com
Thank you
Alan Parkinson
CEO and Co-founder, Hindsight Software Ltd
alan.parkinson@hindsightsoftware.co.uk
@alan_parkinson

Weitere ähnliche Inhalte

Was ist angesagt?

BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumberDaniel Kummer
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)Rohit Bisht
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Mindfire Solutions
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?QATestLab
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD123abcda
 
BDD presentation
BDD presentationBDD presentation
BDD presentationtemebele
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...KMS Technology
 
Behavior Driven Development Pros and Cons
Behavior Driven Development Pros and ConsBehavior Driven Development Pros and Cons
Behavior Driven Development Pros and ConsIosif Itkin
 
Successfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile WorldSuccessfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile WorldSmartBear
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber Knoldus Inc.
 
DevCamp - O papel de um testador em uma equipe ágil
DevCamp - O papel de um testador em uma equipe ágilDevCamp - O papel de um testador em uma equipe ágil
DevCamp - O papel de um testador em uma equipe ágilElias Nogueira
 
An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)Suman Guha
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationJohn Ferguson Smart Limited
 

Was ist angesagt? (20)

Cucumber presenation
Cucumber presenationCucumber presenation
Cucumber presenation
 
BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Automated Test Framework with Cucumber
Automated Test Framework with CucumberAutomated Test Framework with Cucumber
Automated Test Framework with Cucumber
 
What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
BDD presentation
BDD presentationBDD presentation
BDD presentation
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
 
Behavior Driven Development Pros and Cons
Behavior Driven Development Pros and ConsBehavior Driven Development Pros and Cons
Behavior Driven Development Pros and Cons
 
Successfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile WorldSuccessfully Implementing BDD in an Agile World
Successfully Implementing BDD in an Agile World
 
BDD & Cucumber
BDD & CucumberBDD & Cucumber
BDD & Cucumber
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 
BDD in Action - building software that matters
BDD in Action - building software that mattersBDD in Action - building software that matters
BDD in Action - building software that matters
 
DevCamp - O papel de um testador em uma equipe ágil
DevCamp - O papel de um testador em uma equipe ágilDevCamp - O papel de um testador em uma equipe ágil
DevCamp - O papel de um testador em uma equipe ágil
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
 
An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)An introduction to Behavior-Driven Development (BDD)
An introduction to Behavior-Driven Development (BDD)
 
BDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world applicationBDD in Action – principles, practices and real-world application
BDD in Action – principles, practices and real-world application
 

Ähnlich wie Test automation with Cucumber-JVM

Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for seleniumapoorvams
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
QA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiously
QA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiouslyQA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiously
QA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiouslyQAFest
 
Testing Big Data solutions fast and furiously
Testing Big Data solutions fast and furiouslyTesting Big Data solutions fast and furiously
Testing Big Data solutions fast and furiouslyKatherine Golovinova
 
Byteman - Carving up your Java code
Byteman - Carving up your Java codeByteman - Carving up your Java code
Byteman - Carving up your Java codeChris Sinjakli
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Baruch Sadogursky
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmAnton Shapin
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxsandeshshahapur
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddSrinivasa GV
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in RSamuel Bosch
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIDirk Ginader
 
Sexy Using Cucumber - BDD in your project
Sexy Using Cucumber - BDD in your projectSexy Using Cucumber - BDD in your project
Sexy Using Cucumber - BDD in your projectb4usolution .
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Being Expressive in Code
Being Expressive in CodeBeing Expressive in Code
Being Expressive in CodeEamonn Boyle
 

Ähnlich wie Test automation with Cucumber-JVM (20)

Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
QA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiously
QA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiouslyQA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiously
QA Fest 2019. Дмитрий Собко. Testing Big Data solutions fast and furiously
 
Testing Big Data solutions fast and furiously
Testing Big Data solutions fast and furiouslyTesting Big Data solutions fast and furiously
Testing Big Data solutions fast and furiously
 
Byteman - Carving up your Java code
Byteman - Carving up your Java codeByteman - Carving up your Java code
Byteman - Carving up your Java code
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Useful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptx
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tdd
 
Struts2
Struts2Struts2
Struts2
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in R
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
 
Sexy Using Cucumber - BDD in your project
Sexy Using Cucumber - BDD in your projectSexy Using Cucumber - BDD in your project
Sexy Using Cucumber - BDD in your project
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Being Expressive in Code
Being Expressive in CodeBeing Expressive in Code
Being Expressive in Code
 

Mehr von Alan Parkinson

Test Data Builder Pattern
Test Data Builder PatternTest Data Builder Pattern
Test Data Builder PatternAlan Parkinson
 
Testing requirements with BDD
Testing requirements with BDDTesting requirements with BDD
Testing requirements with BDDAlan Parkinson
 
Baking in the cloud with packer and puppet
Baking in the cloud with packer and puppetBaking in the cloud with packer and puppet
Baking in the cloud with packer and puppetAlan Parkinson
 
Decapitating Selenium with JavaScript
Decapitating Selenium with JavaScriptDecapitating Selenium with JavaScript
Decapitating Selenium with JavaScriptAlan Parkinson
 
Pull requests and testers can be friends
Pull requests and testers can be friendsPull requests and testers can be friends
Pull requests and testers can be friendsAlan Parkinson
 
What is Continuous Delivery?
What is Continuous Delivery?What is Continuous Delivery?
What is Continuous Delivery?Alan Parkinson
 
Cross browser Testing JavaScript
Cross browser Testing JavaScriptCross browser Testing JavaScript
Cross browser Testing JavaScriptAlan Parkinson
 
Why we used Feature Branching
Why we used Feature BranchingWhy we used Feature Branching
Why we used Feature BranchingAlan Parkinson
 
A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)Alan Parkinson
 
Cross-browser unit testing JavaScript
Cross-browser unit testing JavaScriptCross-browser unit testing JavaScript
Cross-browser unit testing JavaScriptAlan Parkinson
 
Creating data with the test data builder pattern
Creating data with the test data builder patternCreating data with the test data builder pattern
Creating data with the test data builder patternAlan Parkinson
 
Acceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs DeclarativeAcceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs DeclarativeAlan Parkinson
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenAlan Parkinson
 
Feature branching a release day painkiller
Feature branching   a release day painkillerFeature branching   a release day painkiller
Feature branching a release day painkillerAlan Parkinson
 

Mehr von Alan Parkinson (14)

Test Data Builder Pattern
Test Data Builder PatternTest Data Builder Pattern
Test Data Builder Pattern
 
Testing requirements with BDD
Testing requirements with BDDTesting requirements with BDD
Testing requirements with BDD
 
Baking in the cloud with packer and puppet
Baking in the cloud with packer and puppetBaking in the cloud with packer and puppet
Baking in the cloud with packer and puppet
 
Decapitating Selenium with JavaScript
Decapitating Selenium with JavaScriptDecapitating Selenium with JavaScript
Decapitating Selenium with JavaScript
 
Pull requests and testers can be friends
Pull requests and testers can be friendsPull requests and testers can be friends
Pull requests and testers can be friends
 
What is Continuous Delivery?
What is Continuous Delivery?What is Continuous Delivery?
What is Continuous Delivery?
 
Cross browser Testing JavaScript
Cross browser Testing JavaScriptCross browser Testing JavaScript
Cross browser Testing JavaScript
 
Why we used Feature Branching
Why we used Feature BranchingWhy we used Feature Branching
Why we used Feature Branching
 
A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)A Quick overview of Behaviour Driven Development (BDD)
A Quick overview of Behaviour Driven Development (BDD)
 
Cross-browser unit testing JavaScript
Cross-browser unit testing JavaScriptCross-browser unit testing JavaScript
Cross-browser unit testing JavaScript
 
Creating data with the test data builder pattern
Creating data with the test data builder patternCreating data with the test data builder pattern
Creating data with the test data builder pattern
 
Acceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs DeclarativeAcceptance test styles - Imperative vs Declarative
Acceptance test styles - Imperative vs Declarative
 
Continuous Deployment Pipeline with maven
Continuous Deployment Pipeline with mavenContinuous Deployment Pipeline with maven
Continuous Deployment Pipeline with maven
 
Feature branching a release day painkiller
Feature branching   a release day painkillerFeature branching   a release day painkiller
Feature branching a release day painkiller
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Test automation with Cucumber-JVM

  • 1. Boston Java Meetup, 13/06/2013 Test Automation with Cucumber-JVM Alan Parkinson @alan_parkinson
  • 2. Cucumber is a tool that executes plain-text functional descriptions as automated tests • Tests written in business-facing text  Supports over 40 spoken languages  This test is called Gherkin • Automation written in target language  Ruby, Java, Scala, Groovy, etc.. .net, python, PHP
  • 4. • Program does not do what it is intended • Fixed in development/QA • Program does what is intended • Unstated, misunderstood or tacit requirements IMPLEMENTATION DEFECT REQUIREMENTS DEFECT Software - What can go wrong?
  • 5. A woman asks her husband, a programmer, to go shopping. She tells him “please, go to the nearby grocery store to buy some bread. Also, if they have eggs, buy 6”
  • 6. 50-60%of issues identified by testers can be chalked down as Requirements Defects 100-200%more expensive to fix than other defects because the code is already written
  • 7. How does BDD help? • All stakeholders involved in the discussion drives out clear and concise specifications centred around business value. • Write specifications in natural language so everyone is on the same page • Turn the specification into acceptance tests that guarantees the software does as it is intended • Use those tests as the software evolves to guarantee that it continues to work as intended. • Specifications are documentation – each scenario describes how the system is being used
  • 8. Cucumber, The Origins • Cucumber  Ruby  Born 2007-2008 • Cuke4Duke  First seen in 2008  JRuby • Cucumber-JVM  Released April 2012  Java, Groovy, Clojure, Scala, Ioke, Jython, Rhino (JavaScript) and JRuby
  • 11. Scenarios - Given When Then Given an owner with a registered pet called “Sly“ When the owner registers a new pet called “Sly“ Then the user should be warned that the pet already exists
  • 12. Writing Scenario's in Cucumber • Scenarios are organized together into features • Each feature is represented as a plain text file. • Feature files must have the “.feature” extension • Each feature can contain many scenarios
  • 13. JUnit Runner import org.junit.runner.RunWith; import cucumber.junit.Cucumber; @RunWith(Cucumber.class) public class RunnerIT { }
  • 14. JUnit Runner 2 • Body of the class should be empty  No @Test annotated methods  No @Before or @After methods • Arguments can be provided with an additional annotation
  • 15. JUnit Runner - Arguments @RunWith(Cucumber.class) @Cucumber.Options( features = "src/test/resources/features“ ) public class RunnerIT { }
  • 16. Step Definitions • A single Method representing a Step from a Feature file • The Method is annotated with information about the step it represents • Cucumber generates “Code Snippet's” for Step Definition it can’t find
  • 17. Step Annotations import cucumber.annotation.en.*; Each Gherkin step keyword has a Annotation @When("^we want to stop traffic$") public void methodName() { … }
  • 18. Passing and Failing • Each step has it own result state  Passed  Pending  Skipped  Failed • Individual step result state combined determine the Scenarios success or failure • Steps can be failed on exceptions or JUnit Assertion failures
  • 19. Regex Lesson Cucumber uses Regular Expressions to match steps to definitions. @When("^we want to stop traffic$") ^ Matches the starting position $ Matches the ending position
  • 20. Capturing Arguments @Given("^an owner with a pet called "Sly"$") public void an_owner_with_a_pet_called() { … } @Given("^an owner with a pet called "([^"]*)"$") public void an_owner_with_a_pet_called(String name) { … }
  • 21. Capturing Arguments 2 • The pair of brackets is a capture group • Everything captured is passed to method parameter • Cucumber will automatically convert to the method parameter type • Equal number of method parameters and capture groups
  • 22. Type Conversion • If the captured string is not in the correct format for type conversion an error will be thrown • Use regular expressions to capture the correct format string for the type Note: Escape regular expression characters with backslash
  • 23. Typical Capture Groups (.+) Good for capturing strings and dates "([^"]*)" Captures a string within Double quotes (d) Capture decimal numbers only (d+.d+) Capture floating point numbers (true|false) Captures a Boolean value
  • 24. Date Formats @Given ("^today is (.+)$") public void today_is(Date date) { …. } Dates are recognized if it’s a format from the DateFormat class
  • 25. Date Formats SHORT is completely numeric, such as 12.13.52 or 3:30pm MEDIUM is longer, such as Jan 12, 1952 LONG is longer, such as January 12, 1952 or 3:30:32pm FULL is pretty completely specified, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.
  • 26. Date Formats import cucumber.DateFormat; @Given ("^today is (.+)$") public void today_is( @DateFormat ("yyyy-MM-dd") Date date) { …. }
  • 27. Tag use cases • Grouping Scenarios together  Identify slow running test that shouldn’t be run frequently  Identify tests that require a particular library or server
  • 28. Running Scenarios with a Tag @Cucumber.Options( tags = {“@WebDriver”}, … )
  • 29. Running Scenarios without a Tag Cucumber can exclude Scenarios with a particular tag by inserting the tilde character before the tag For the following command will run all Scenarios without the WebDriver tag @Cucumber.Options( tags = {“~@WebDriver”}, … )
  • 30. Tag expressions – Logical OR Separate a list of tags by commas for a Logical OR tag expression @Cucumber.Options( tags = {“@WebDriver,@email”}, … )
  • 31. Tag expressions – Logical AND Specifying multiple tag arguments creates a logical AND between each tag expression. @Cucumber.Options( tags = {“@WebDriver”, ”@email”}, … )
  • 32. Tag expressions – AND OR Run scenarios that are tagged with @WebDriver or @email but not @slow @Cucumber.Options( tags = {“@WebDriver,@email”, “~@slow”}, … )
  • 33. Further information Official website: cukes.info Github: github.com/cucumber/cucumber-jvm Hindsight Software: hindsighttesting.com
  • 34. Thank you Alan Parkinson CEO and Co-founder, Hindsight Software Ltd alan.parkinson@hindsightsoftware.co.uk @alan_parkinson

Hinweis der Redaktion

  1. The husband brings home 6 loaves of bread!