SlideShare uma empresa Scribd logo
1 de 24
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

Mais conteúdo relacionado

Mais procurados

Angular state Management-NgRx
Angular state Management-NgRxAngular state Management-NgRx
Angular state Management-NgRxKnoldus Inc.
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2Self-Employed
 
Exploring Modeling - Doing More with Lists
Exploring Modeling - Doing More with ListsExploring Modeling - Doing More with Lists
Exploring Modeling - Doing More with ListsRonen Botzer
 
Study of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramStudy of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramMeenakshi Devi
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferencesAjay Panchal
 
Different Sorting tecniques in Data Structure
Different Sorting tecniques in Data StructureDifferent Sorting tecniques in Data Structure
Different Sorting tecniques in Data StructureTushar Gonawala
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 
Architecture of the Web browser
Architecture of the Web browserArchitecture of the Web browser
Architecture of the Web browserSabin Buraga
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search treeKrish_ver2
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms ArraysManishPrajapati78
 
Java CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server DatabaseJava CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server DatabaseDudy Ali
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary searchnikunjandy
 

Mais procurados (20)

Angular state Management-NgRx
Angular state Management-NgRxAngular state Management-NgRx
Angular state Management-NgRx
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
Exploring Modeling - Doing More with Lists
Exploring Modeling - Doing More with ListsExploring Modeling - Doing More with Lists
Exploring Modeling - Doing More with Lists
 
Study of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proramStudy of aloha protocol using ns2 network java proram
Study of aloha protocol using ns2 network java proram
 
Android share preferences
Android share preferencesAndroid share preferences
Android share preferences
 
Different Sorting tecniques in Data Structure
Different Sorting tecniques in Data StructureDifferent Sorting tecniques in Data Structure
Different Sorting tecniques in Data Structure
 
Selection sort
Selection sortSelection sort
Selection sort
 
Architecture of the Web browser
Architecture of the Web browserArchitecture of the Web browser
Architecture of the Web browser
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
 
Data Structure and Algorithms Arrays
Data Structure and Algorithms ArraysData Structure and Algorithms Arrays
Data Structure and Algorithms Arrays
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Java CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server DatabaseJava CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server Database
 
java Jdbc
java Jdbc java Jdbc
java Jdbc
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Ajax and Jquery
Ajax and JqueryAjax and Jquery
Ajax and Jquery
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
 
Pandas
PandasPandas
Pandas
 

Semelhante a Useful practices of creation automatic tests by using cucumber jvm

Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous deliveryEatDog
 
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 ExampleNalin 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 applicationsEvgeniy 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 CloudMatt Callanan
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience reportYan 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 SummitOrtus 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 PartnersCraeg 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 STAMPSté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 jasmineGil 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 CIwajrcs
 

Semelhante a 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
 

Último

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

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

Notas do Editor

  1. .