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

Php Error Handling
Php Error HandlingPhp Error Handling
Php Error Handling
mussawir20
 
State management
State managementState management
State management
Iblesoft
 

What's hot (20)

plsql.ppt
plsql.pptplsql.ppt
plsql.ppt
 
SQL Server Stored procedures
SQL Server Stored proceduresSQL Server Stored procedures
SQL Server Stored procedures
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group Functions
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
Clean code
Clean codeClean code
Clean code
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
 
6. static keyword
6. static keyword6. static keyword
6. static keyword
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Java Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, LoopsJava Foundations: Basic Syntax, Conditions, Loops
Java Foundations: Basic Syntax, Conditions, Loops
 
PHP - Introduction to PHP Error Handling
PHP -  Introduction to PHP Error HandlingPHP -  Introduction to PHP Error Handling
PHP - Introduction to PHP Error Handling
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
 
DDL And DML
DDL And DMLDDL And DML
DDL And DML
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
 
Php Error Handling
Php Error HandlingPhp Error Handling
Php Error Handling
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best Practices
 
State management
State managementState management
State management
 
Bcnf
BcnfBcnf
Bcnf
 

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

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

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

Recently uploaded (20)

IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Intelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdfIntelligent Gimbal FINAL PAPER Engineering.pdf
Intelligent Gimbal FINAL PAPER Engineering.pdf
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.Enterprise Security Monitoring, And Log Management.
Enterprise Security Monitoring, And Log Management.
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
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
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
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
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 

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. .