SlideShare a Scribd company logo
1
Useful practices of creation
automatic tests by using
Cucumber-JVM
Shapin Anton
November 19, 2016
2
• Lead Software Test Automation Engineer
• 9+ years in IT
• Areas of my competency: manual,
automation, performance and etc.
• Successfully completed 9 BDD projects.
• 1 BDD projects in progress.
Email: anton_shapin@epam.com
Skype: anton_shapin
GIT: http://github.com/kirlionik
Shapin Anton
3
Agenda
BDD approach(3 small slides)1
Best Practices2
Parallel mode3
Questions4
4
LET`S START !
5
BDD approach
BDD(behavior-driven development) - is a set of software engineering practices
designed to help teams build and deliver more valuable, higher quality software faster. It
draws on Agile and lean practices including, in particular, Test-Driven Development (TDD) and
Domain-Driven Design (DDD).
BDD isn’t a software development methodology in its own right. It’s not a replacement
for Scrum, XP, Kanban, RUP, or whatever methodology you’re currently using.
MAIN GOAL: EXECUTABLE SPECIFICATION
6
How it works
@Given("^I perform Quick Search by "([^"]*)" $")
public void i_perform_quick_search_by(String query) {
driver.findElement(By.id(“searchQuery”)).sendKeys(query);
driver.findElement(By.id(“submit”)).click();
}
Scenario: Running a Full Text Quick Search.
Given I perform Quick Search by "IPhone 4S"
...
Each step maps to Java Method
File *.feature
File *.class
Example of GUI Scenario
Scenario: Running a Full Text Quick Search.
Given I perform Quick Search by "IPhone 4S"
When I click on link 'Search History' on panel 'Quick Search'
Then the term query "IPhone 4S" should be the first in the Search
History grid
8
The main layers of a Cucumber test suite
9
Why I like BDD:
Test logic is in total independent
layer of implementation.
1
All test cases and automated
tests are up to date.
2
BA could accept user-story base
on test execution report.
3
Manual or Junior qa
automation engineers help
me develop automated tests.
4
Example of Web Service
IP Address Geolocation XML API
The API returns the location of an IP address (country, region, city, zip code, latitude, longitude) and the associated
time zone in XML format.
Usage:
For country precision (faster), do a query with the following API :
IPv4 Address
http://localhost.com/v5/ip-country/?key=<your_api_key>&ipv4=74.125.45.100
IPv6 Address
http://localhost.com/v5/ip-country/?key=<your_api_key>&ipv6=2001:0200:0102::
http://localhost.com/v4/ip-city/?key=<your_api_key>&ip=74.125.45.100
For city precision, do a query with the following API (if you omit the IP parameter it will check with your own IP) :
Best Practices. Test Step Creation.
Create template of steps:
WHEN:
• I set the …
• I send request to …
• I add …
Then:
• I get … .
• the report should contain ...
• the values of the ...
WHEN:
• I set the key as «12Gth6Ntds»
• I send request to Geo City
• I add the ip «74.125.45.100»
Then:
• I get http status as "200"
• the report should contain country «USA»
This will help find existing steps and creating a new steps
Best Practices. Test Step Creation.
This will help to find the existing steps and
do not make a mistake in the name of the parameter
Name of parameter must not be a variable
@When("^I set the key as "([^"]*)" $")
public void i_set_key(int number) {
// TODO: code goes here
}
@When("^I set the "([^"]*)" as "([^"]*)" $")
public void i_set_param(String name, int number) {
// TODO: code goes here
}
Given I set the “key” as “12Gth6Ntds”
Given I set the “ip” as “74.125.45.100” Given I set the key as “12Gth6Ntds”
BAD GOOD
Best Practices. Test Step Creation.
This will help understand function of steps
Create Javadoc before each Step definition methods
Best Practices. Test Step Creation.
User Helpers. For example IntelliJ IDEA plugin «Cucumber for Java»
15
Best Practices. Test Step Creation.
1. Separating the Support Code
2. Favorite way to organize step definition files is to organize
them with one file per domain entity: GeoCityStepDef.class,
GeoCountryStepDef.class.
3. By default Cucumber find StepDef classes in the same
package as *.feature files.
Organizing the Code
Best Practices. Test Step Creation.
This will help you get more understandable tests reports
Use cucumber plugins for reporting.
@CucumberOptions(
strict = true,
plugin = {
"com.github.kirlionik.cucumberallure.AllureReporter",
"pretty", "json:target/Cucumber.json",
"html:target/cucumber-html-report"
}
)
You can develop your own Cucumber plugins.
Best Practices. Test Step Creation.
Use cucumber plugins for reporting.
com.github.kirlionik.cucumberallure.AllureReporter
@SeverityLevel.CRITICAL @TestCaseId("geo-0001") @Issue(“geo-1006")
Scenario: Check city by ipv4
Given I set the key as "asd-asd-asd"
And I set the ip as "123.123.123.123"
When I send request to Geo City
Then I get http status as "200"
And the report should contain country "USA"
And the report should contain city "New York"
You can:
• Define Severity of each scenario.
• Create link to issue.
• Link to user-story.
• Create attachments.
• Other Allure Core features …
This will help you get more understandable tests reports
Best Practices. Test Step Creation.
Use cucumber plugins for reporting.
com.github.kirlionik.cucumberallure.AllureReporter
Best Practices. Test Step Creation.
public class Container {
public GeoServiceOutput output;
public String key;
public String ip;
}
All steps in Cucumber are independent.
This will help you develop automated tests and
use complex architecture of tests system.
Use class “Container” for transfer data between stepDef
methods and classes.
Best Practices.
Feel free to use parallel mode for test execution.
This will reduce tests execution time.
For example. How to:
• Create several “runner” classes with name “*ParallelIT.class”
• Define tags of features in each “runner” class.
You shouldn`t have the same tags in different “runner”
classes.
• Add profile into pom.xml file:
• Add parameters in Configuration section of “maven-failsafe-
plugin”:
• For execute tests run command:
mvn clean install -Pparallel
<profile>
<id>parallel</id>
<properties>
<junit.threadCount>4</junit.threadCount>
<junit.parallel>classes</junit.parallel>
<run.classes>**/*ParallelIT.class</run.classes>
</properties>
</profile>
<reuseForks>false</reuseForks>
<forkCount>20</forkCount>
<threadCount>${junit.threadCount}</threadCount>
<parallel>${junit.parallel}</parallel>
In my current project I reduced execution time from 30 min to 10 min
Best Practices.
You can transfer to Java StepDef method complex objects.
….
Then the report should have the next formatting:
| text | color | font | size | bold | type |
| Country | Black | Arial | 28 | true | NORMAL |
| Ip address | RED | Calibri | 20 | false | NORMAL |
@Then("^the report should have the next formatting$")
public void check_the_report_style(List<StyledText> styledTextsList) {
// TODO: code goes here
}
public class StyledText {
private String text;
private String color;
private String font;
private Integer size;
private boolean bold;
private String type;
}
Cucumber create objects of StyledText automatically.
22
Summary
1. Create Javadoc before each Step definition methods.
2. Create template of steps.
3. Name of parameter must not be a variable.
4. Use cucumber plugins for reporting.
5. Very carefully think through the architecture of your test
system (What? Where? Why? How?).
23
Conclusion
1. BDD is a very good approach. But this is not a magic bullet.
2. Most difficult things in BDD are create good test system
architecture and define «Rules of the game»
3. To use or not to use BDD depends on situation and project.
24
Thank you for attention!
Email: anton_shapin@epam.com
Skype: anton_shapin
GIT: http://github.com/kirlionik

More Related Content

What's hot

Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Softwarel xf
 
실전 서버 부하테스트 노하우
실전 서버 부하테스트 노하우 실전 서버 부하테스트 노하우
실전 서버 부하테스트 노하우
YoungSu Son
 
Intro sur les tests unitaires
Intro sur les tests unitairesIntro sur les tests unitaires
Intro sur les tests unitairesPHPPRO
 
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsAndroid Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
DroidConTLV
 
Cataloging People: A critical response to the treatment of queer identities i...
Cataloging People: A critical response to the treatment of queer identities i...Cataloging People: A critical response to the treatment of queer identities i...
Cataloging People: A critical response to the treatment of queer identities i...
Amber Billey
 
Unirest Java Tutorial | Java Http Client
Unirest Java Tutorial | Java Http ClientUnirest Java Tutorial | Java Http Client
Unirest Java Tutorial | Java Http Client
rahul patel
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
National Cheng Kung University
 
Core Java Equals and hash code
Core Java Equals and hash codeCore Java Equals and hash code
Core Java Equals and hash code
mhtspvtltd
 

What's hot (8)

Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Software
 
실전 서버 부하테스트 노하우
실전 서버 부하테스트 노하우 실전 서버 부하테스트 노하우
실전 서버 부하테스트 노하우
 
Intro sur les tests unitaires
Intro sur les tests unitairesIntro sur les tests unitaires
Intro sur les tests unitaires
 
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsAndroid Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
 
Cataloging People: A critical response to the treatment of queer identities i...
Cataloging People: A critical response to the treatment of queer identities i...Cataloging People: A critical response to the treatment of queer identities i...
Cataloging People: A critical response to the treatment of queer identities i...
 
Unirest Java Tutorial | Java Http Client
Unirest Java Tutorial | Java Http ClientUnirest Java Tutorial | Java Http Client
Unirest Java Tutorial | Java Http Client
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Core Java Equals and hash code
Core Java Equals and hash codeCore Java Equals and hash code
Core Java Equals and hash code
 

Similar to Useful practices of creation automatic tests by using cucumber jvm

Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
EatDog
 
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Evgeniy Kuzmin
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Nalin Goonawardana
 
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applicationsContinuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
Evgeniy Kuzmin
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
Yan Cui
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
Yan Cui
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)
Yan Cui
 
Priming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudPriming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the Cloud
Matt Callanan
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience report
Yan Cui
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Ortus Solutions, Corp
 
Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)
Yan Cui
 
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
Craeg Strong
 
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
Craeg Strong
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)
Yan Cui
 
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPInria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Stéphanie Roger
 
Serverless in production, an experience report (linuxing in london)
Serverless in production, an experience report (linuxing in london)Serverless in production, an experience report (linuxing in london)
Serverless in production, an experience report (linuxing in london)
Yan Cui
 
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
Yan Cui
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
Gil Fink
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
wajrcs
 

Similar to Useful practices of creation automatic tests by using cucumber jvm (20)

Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
 
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applicationsContinuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)
 
Priming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudPriming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the Cloud
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience report
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)
 
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
 
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
20211202 NADOG Adapting to Covid with Serverless Craeg Strong Ariel Partners
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)
 
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPInria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
 
Serverless in production, an experience report (linuxing in london)
Serverless in production, an experience report (linuxing in london)Serverless in production, an experience report (linuxing in london)
Serverless in production, an experience report (linuxing in london)
 
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
 

Recently uploaded

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 

Recently uploaded (20)

To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 

Useful practices of creation automatic tests by using cucumber jvm

  • 1. 1 Useful practices of creation automatic tests by using Cucumber-JVM Shapin Anton November 19, 2016
  • 2. 2 • Lead Software Test Automation Engineer • 9+ years in IT • Areas of my competency: manual, automation, performance and etc. • Successfully completed 9 BDD projects. • 1 BDD projects in progress. Email: anton_shapin@epam.com Skype: anton_shapin GIT: http://github.com/kirlionik Shapin Anton
  • 3. 3 Agenda BDD approach(3 small slides)1 Best Practices2 Parallel mode3 Questions4
  • 5. 5 BDD approach BDD(behavior-driven development) - is a set of software engineering practices designed to help teams build and deliver more valuable, higher quality software faster. It draws on Agile and lean practices including, in particular, Test-Driven Development (TDD) and Domain-Driven Design (DDD). BDD isn’t a software development methodology in its own right. It’s not a replacement for Scrum, XP, Kanban, RUP, or whatever methodology you’re currently using. MAIN GOAL: EXECUTABLE SPECIFICATION
  • 6. 6 How it works @Given("^I perform Quick Search by "([^"]*)" $") public void i_perform_quick_search_by(String query) { driver.findElement(By.id(“searchQuery”)).sendKeys(query); driver.findElement(By.id(“submit”)).click(); } Scenario: Running a Full Text Quick Search. Given I perform Quick Search by "IPhone 4S" ... Each step maps to Java Method File *.feature File *.class
  • 7. Example of GUI Scenario Scenario: Running a Full Text Quick Search. Given I perform Quick Search by "IPhone 4S" When I click on link 'Search History' on panel 'Quick Search' Then the term query "IPhone 4S" should be the first in the Search History grid
  • 8. 8 The main layers of a Cucumber test suite
  • 9. 9 Why I like BDD: Test logic is in total independent layer of implementation. 1 All test cases and automated tests are up to date. 2 BA could accept user-story base on test execution report. 3 Manual or Junior qa automation engineers help me develop automated tests. 4
  • 10. Example of Web Service IP Address Geolocation XML API The API returns the location of an IP address (country, region, city, zip code, latitude, longitude) and the associated time zone in XML format. Usage: For country precision (faster), do a query with the following API : IPv4 Address http://localhost.com/v5/ip-country/?key=<your_api_key>&ipv4=74.125.45.100 IPv6 Address http://localhost.com/v5/ip-country/?key=<your_api_key>&ipv6=2001:0200:0102:: http://localhost.com/v4/ip-city/?key=<your_api_key>&ip=74.125.45.100 For city precision, do a query with the following API (if you omit the IP parameter it will check with your own IP) :
  • 11. Best Practices. Test Step Creation. Create template of steps: WHEN: • I set the … • I send request to … • I add … Then: • I get … . • the report should contain ... • the values of the ... WHEN: • I set the key as «12Gth6Ntds» • I send request to Geo City • I add the ip «74.125.45.100» Then: • I get http status as "200" • the report should contain country «USA» This will help find existing steps and creating a new steps
  • 12. Best Practices. Test Step Creation. This will help to find the existing steps and do not make a mistake in the name of the parameter Name of parameter must not be a variable @When("^I set the key as "([^"]*)" $") public void i_set_key(int number) { // TODO: code goes here } @When("^I set the "([^"]*)" as "([^"]*)" $") public void i_set_param(String name, int number) { // TODO: code goes here } Given I set the “key” as “12Gth6Ntds” Given I set the “ip” as “74.125.45.100” Given I set the key as “12Gth6Ntds” BAD GOOD
  • 13. Best Practices. Test Step Creation. This will help understand function of steps Create Javadoc before each Step definition methods
  • 14. Best Practices. Test Step Creation. User Helpers. For example IntelliJ IDEA plugin «Cucumber for Java»
  • 15. 15 Best Practices. Test Step Creation. 1. Separating the Support Code 2. Favorite way to organize step definition files is to organize them with one file per domain entity: GeoCityStepDef.class, GeoCountryStepDef.class. 3. By default Cucumber find StepDef classes in the same package as *.feature files. Organizing the Code
  • 16. Best Practices. Test Step Creation. This will help you get more understandable tests reports Use cucumber plugins for reporting. @CucumberOptions( strict = true, plugin = { "com.github.kirlionik.cucumberallure.AllureReporter", "pretty", "json:target/Cucumber.json", "html:target/cucumber-html-report" } ) You can develop your own Cucumber plugins.
  • 17. Best Practices. Test Step Creation. Use cucumber plugins for reporting. com.github.kirlionik.cucumberallure.AllureReporter @SeverityLevel.CRITICAL @TestCaseId("geo-0001") @Issue(“geo-1006") Scenario: Check city by ipv4 Given I set the key as "asd-asd-asd" And I set the ip as "123.123.123.123" When I send request to Geo City Then I get http status as "200" And the report should contain country "USA" And the report should contain city "New York" You can: • Define Severity of each scenario. • Create link to issue. • Link to user-story. • Create attachments. • Other Allure Core features … This will help you get more understandable tests reports
  • 18. Best Practices. Test Step Creation. Use cucumber plugins for reporting. com.github.kirlionik.cucumberallure.AllureReporter
  • 19. Best Practices. Test Step Creation. public class Container { public GeoServiceOutput output; public String key; public String ip; } All steps in Cucumber are independent. This will help you develop automated tests and use complex architecture of tests system. Use class “Container” for transfer data between stepDef methods and classes.
  • 20. Best Practices. Feel free to use parallel mode for test execution. This will reduce tests execution time. For example. How to: • Create several “runner” classes with name “*ParallelIT.class” • Define tags of features in each “runner” class. You shouldn`t have the same tags in different “runner” classes. • Add profile into pom.xml file: • Add parameters in Configuration section of “maven-failsafe- plugin”: • For execute tests run command: mvn clean install -Pparallel <profile> <id>parallel</id> <properties> <junit.threadCount>4</junit.threadCount> <junit.parallel>classes</junit.parallel> <run.classes>**/*ParallelIT.class</run.classes> </properties> </profile> <reuseForks>false</reuseForks> <forkCount>20</forkCount> <threadCount>${junit.threadCount}</threadCount> <parallel>${junit.parallel}</parallel> In my current project I reduced execution time from 30 min to 10 min
  • 21. Best Practices. You can transfer to Java StepDef method complex objects. …. Then the report should have the next formatting: | text | color | font | size | bold | type | | Country | Black | Arial | 28 | true | NORMAL | | Ip address | RED | Calibri | 20 | false | NORMAL | @Then("^the report should have the next formatting$") public void check_the_report_style(List<StyledText> styledTextsList) { // TODO: code goes here } public class StyledText { private String text; private String color; private String font; private Integer size; private boolean bold; private String type; } Cucumber create objects of StyledText automatically.
  • 22. 22 Summary 1. Create Javadoc before each Step definition methods. 2. Create template of steps. 3. Name of parameter must not be a variable. 4. Use cucumber plugins for reporting. 5. Very carefully think through the architecture of your test system (What? Where? Why? How?).
  • 23. 23 Conclusion 1. BDD is a very good approach. But this is not a magic bullet. 2. Most difficult things in BDD are create good test system architecture and define «Rules of the game» 3. To use or not to use BDD depends on situation and project.
  • 24. 24 Thank you for attention! Email: anton_shapin@epam.com Skype: anton_shapin GIT: http://github.com/kirlionik

Editor's Notes

  1. .