SlideShare uma empresa Scribd logo
1 de 32
MAKE BDD GREAT AGAIN :)
P R O T R A C T O R & C U C U M B E R
IANA KOKRIASHKINA
Skype: yanochka_3007
email: yana.gusti@gmail.com
MAIN TASK
Code review of existing tests
Save current project
Do better on new projects
STEP DEFINITIONS
CODE REVIEW OF PROJECT STRUCTURE
• Each feature has it’s own step-definition file
• Each step has it’s own implementation
WHAT CUCUMBER TUTORIALS SAY
https://cucumber.io/docs/gherkin/step-organization/
JETBRAINS USER GUIDE
https://www.jetbrains.com/help/idea/creating-step-definition.html
FIRST STEPS TO SAVE PROJECT
• 1 actions file and one verifications file
REPORTS REVIEW
REPORTS REVIEW
No reporting
Main problem of testing - its absence
STEPS IMPLEMENTATION
IMPLEMENTATIONS OF CUCUMBER STEPS
• Some steps were not implemented
• Some functions were overcomplicated
REPLACE REGEXP WITH CUCUMBER EXPRESSIONS
• Parameter types - https://cucumber.io/docs/cucumber/cucumber-expressions/
IMPLEMENT YOUR OWN TYPES
{url}
defineParameterType({
name: 'url',
transformer(string) {
if (string.indexOf('http') === 0) {
return string;
}
return object.urls[string][environment];
}
});
urls: {
MAIN_URL: {
DEV: "https://test.com",
LOCAL: "http://localhost:3000"
},
API: {
DEV: "https://test.com/#/api",
LOCAL: "http://localhost:3000#/api"
},
IMPLEMENT YOUR OWN TYPES
{user}
defineParameterType({
name: 'user',
transformer(role) {
return object.users[role][environment];
}
});
users: {
USER: {
DEV: {
login: "test", password: "test"
},
PROD: {
login: "user_test@test.com", password: "1234"
}
},
ADMIN: {
DEV: {
login: "admin", password: "admin"
},
PROD: {
login: "admin_test@test.com", password: "123456"
}
}
}
IMPLEMENT YOUR OWN TYPES
In *.feature file
User logs in as "USER" on "MAIN”
User logs in as "ADMIN" on "API"
users: {
USER: {
DEV: {
login: "test", password: "test"
},
……
ADMIN: {
DEV: {
login: "admin", password: "admin"
},
____________________________
urls: {
MAIN: {
DEV: "http://juliemr.github.io/protractor-demo/",
……..
API: {
DEV: "http://juliemr.github.io/protractor-demo/api",
In conf.js
params: {
timeout: 3000,
env: process.env.TEST_ENV ||
'LOCAL',
},
process.env.TEST_ENV = DEV
SETUP JENKINS JOB
#!/usr/bin/env bash
# Use this script to run tests
npm i
npm run webdriver &
# Wait for port 5555 to be listening connections
chmod +x wait-for-it.sh && ./wait-for-it.sh -t 60 127.0.0.1:5555 -- echo "driver is up"
npm run test-jenkins
LOCALIZATION TESTING
LOCALIZATION TESTING
• Parameter type to check text depending of specified language
defineParameterType({
name: 'text',
transformer: function (s) {
if (s.indexOf(':') !== -1) {
let dataArray = s.split(':');
let page = dataArray[0];
let textToVerify = dataArray[1];
return text[page][textToVerify][language];
}
return s;
}
});
mainPage: {
pageTitle: {
ENG: "Wikipedia, the free encyclopedia",
RU: "Википедия — свободная энциклопедия"
………..
WIKI: {
DEV:{
RU: "https://ru.wikipedia.org/",
ENG: "https://en.wikipedia.org/"
},
},
params: {
env: process.env.TEST_ENV || 'DEV',
lan: process.env.TEST_LAN || 'ENG'
},
TEST SPECIAL SYMBOLS
PARAMETER TYPES WITH REGEXP
defineParameterType({
name: 'text',
transformer: function (s) {
if (s.indexOf('REGEXP:') !== -1) {
s = s.split('REGEXP:')[1];
let dataArray = s.split(':');
let page = dataArray[0];
let textToVerify = dataArray[1];
return new
RegExp(text[page][textToVerify][language]);
}
}
});
todayText: {
ENG: "single's",
RU: "(англ.)русск.,"
}
Then Article "wikiPage|todayText" with text
"REGEXP:mainPage:todayText" is displayed
And Article "wikiPage|todayText" with text
"mainPage:todayText" is displayed
SEVERAL MORE IMPROVEMENTS
1. MULTIPLE BROWSERS
2. REUSING THE BROWSER WINDOW
3. TIMEOUTS
4. ATTACHMENTS
SLACK FOR FAST REPORTING
DO BETTER ON NEW PROJECTS
DO BETTER ON NEW PROJECTS
• Move common steps, helpers, hooks, configurations to the library
• Work with API for preconditions
login: async (host, username, password) => {
let loginRequest = host + "/login";
let data = {"username": username, "password":
password};
let headers = new Map();
headers.set("accept", "application/json");
headers.set("Content-Type", "application/json");
const res = await api.getResponseHeaders("POST",
loginRequest, JSON.stringify(data), headers);
const token = await res['authorization'];
return await global.uniqueMap[token] = token;
},
await userApi.login(host, user.login,
user.password);
When('{user} uploads file to server {landing-url}',
async function (user, host) {
let token = global.uniqueMap[token];
..........
}
REUSE DATA WITHIN SESSION
let response = await apiHelper.sendRequest("GET", url, '',
headers);
return browser.getSession().then(session => {
let body = JSON.parse(response.body);
let coordinates = body['coord'];
let lat = coordinates['lat'];
let lon = coordinates['lon'];
global.uniqueMap[`${session['id_']}lat`] =lat;
global.uniqueMap[`${session['id_']}lon`] =lon;
});
return browser.getSession().then(session => {
let lat = global.uniqueMap[`${session['id_']}lat`];
let lon = global.uniqueMap[`${session['id_']}lon`];
let url = string+'/weather?lat='+lat+'&lon='+lon
let headers = new Map();
headers.set("accept", "application/json");
return apiHelper.sendRequest("GET", url, '',
headers).then(function (response) {
……………..
})
{"b546863e5dc9ea38992a5c5d99570efflat":51.51,"b546863e5dc9ea38992a5c5d99570efflon":-0.13}
WORK WITH FILES
WORK WITH FILES IN HEADLESS MODE
Before(function () {
return browser.getCapabilities().then(caps => {
return browser.getProcessedConfig().then((config) => {
if (caps.get('browserName') === 'chrome') {
return browser.getSession().then(function (session) {
const params = {
cmd: 'Page.setDownloadBehavior',
params: {behavior: 'allow', downloadPath: browser.params.basePath}
};
return endpointHelper.sendRequest('POST',
`${config.seleniumAddress}/session/${session.id_}/chromium/send_command`, JSON.stringify(params));
});
}
});
WORK WITH EXCEL FILES
Then('User verifies that file {string} is downloaded', (fileName) => {
const filePath = browser.params.basePath + fileSep + fileName;
return browser.wait(function () {
return fs.existsSync(filePath);
}, 30000, "Wait for '" + filePath + "' to be downloaded").then(function () {
return true;
});
});
VERIFY FILE BY HASH
• Navigate to https://md5file.com/calculator
• Upload a file that you want to use as template
• Copy calculated value for hash type SHA-1 and paste it into
Then('User verify downloaded file {text} hash is equal to {hash}', function (fileName, hash) {
return expect(fileHelper.getFileHash(fileName)).to.eventually.equal(hash);
});
Then User verify downloaded file "Test.xlsx" hash is equal to "HASH:fileHash”
hashes: {
fileHash: 'e2c39165ebd60772062684d218259370c739b062',
}
GITHUB REPO
https://github.com/yana-gusti/Protractortest
THANK YOU!
YANA.GUSTI@GMAIL.COM
IANA KOKRIASHKINA
@YANA_GUSTI_
YANA.GUSTI.7
IANA KOKRIASHKINA

Mais conteúdo relacionado

Mais procurados

Logstash: Get to know your logs
Logstash: Get to know your logsLogstash: Get to know your logs
Logstash: Get to know your logsSmartLogic
 
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et KibanaJournée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et KibanaPublicis Sapient Engineering
 
Lambda Jam 2015: Event Processing in Clojure
Lambda Jam 2015: Event Processing in ClojureLambda Jam 2015: Event Processing in Clojure
Lambda Jam 2015: Event Processing in ClojureAndy Marks
 
并发模型介绍
并发模型介绍并发模型介绍
并发模型介绍qiang
 
Regex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadRegex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadAll Things Open
 
OSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen LillichOSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen LillichNETWAYS
 
How to configure multiple PostgreSQL-9
How to configure multiple PostgreSQL-9How to configure multiple PostgreSQL-9
How to configure multiple PostgreSQL-9Vivek Singh
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxyIsmael Celis
 
Docker tips & tricks
Docker  tips & tricksDocker  tips & tricks
Docker tips & tricksDharmit Shah
 
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Puppet
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev ConfTom Croucher
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmusBram Vogelaar
 

Mais procurados (20)

Logstash: Get to know your logs
Logstash: Get to know your logsLogstash: Get to know your logs
Logstash: Get to know your logs
 
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et KibanaJournée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
Journée DevOps : Des dashboards pour tous avec ElasticSearch, Logstash et Kibana
 
Elk stack
Elk stackElk stack
Elk stack
 
Lambda Jam 2015: Event Processing in Clojure
Lambda Jam 2015: Event Processing in ClojureLambda Jam 2015: Event Processing in Clojure
Lambda Jam 2015: Event Processing in Clojure
 
并发模型介绍
并发模型介绍并发模型介绍
并发模型介绍
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
 
Regex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language InsteadRegex Considered Harmful: Use Rosie Pattern Language Instead
Regex Considered Harmful: Use Rosie Pattern Language Instead
 
Server Side Swift: Vapor
Server Side Swift: VaporServer Side Swift: Vapor
Server Side Swift: Vapor
 
OSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen LillichOSMC 2014: MonitoringLove with Sensu | Jochen Lillich
OSMC 2014: MonitoringLove with Sensu | Jochen Lillich
 
How to configure multiple PostgreSQL-9
How to configure multiple PostgreSQL-9How to configure multiple PostgreSQL-9
How to configure multiple PostgreSQL-9
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
 
Docker tips & tricks
Docker  tips & tricksDocker  tips & tricks
Docker tips & tricks
 
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
 
Ubic
UbicUbic
Ubic
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
tdc2012
tdc2012tdc2012
tdc2012
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 

Semelhante a Make BDD great again

Introduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release updateIntroduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release updateAlex Pop
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiRan Mizrahi
 
How to automate all your SEO projects
How to automate all your SEO projectsHow to automate all your SEO projects
How to automate all your SEO projectsVincent Terrasi
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerOrtus Solutions, Corp
 
Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Ortus Solutions, Corp
 
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverageTesting NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoveragemlilley
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaKévin Margueritte
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsOhad Kravchick
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsDerek Anderson
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Ilya Haykinson
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 

Semelhante a Make BDD great again (20)

Performance patterns
Performance patternsPerformance patterns
Performance patterns
 
Introduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release updateIntroduction to InSpec and 1.0 release update
Introduction to InSpec and 1.0 release update
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran MizrahiIntro To JavaScript Unit Testing - Ran Mizrahi
Intro To JavaScript Unit Testing - Ran Mizrahi
 
How to automate all your SEO projects
How to automate all your SEO projectsHow to automate all your SEO projects
How to automate all your SEO projects
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Into The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and dockerInto The Box 2018 Going live with commandbox and docker
Into The Box 2018 Going live with commandbox and docker
 
Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018Going live with BommandBox and docker Into The Box 2018
Going live with BommandBox and docker Into The Box 2018
 
Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)
 
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverageTesting NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
 
NodeJS
NodeJSNodeJS
NodeJS
 
FP - Découverte de Play Framework Scala
FP - Découverte de Play Framework ScalaFP - Découverte de Play Framework Scala
FP - Découverte de Play Framework Scala
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Introduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCatsIntroduction to NodeJS with LOLCats
Introduction to NodeJS with LOLCats
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Último (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Make BDD great again

  • 1. MAKE BDD GREAT AGAIN :) P R O T R A C T O R & C U C U M B E R
  • 3. MAIN TASK Code review of existing tests Save current project Do better on new projects
  • 5. CODE REVIEW OF PROJECT STRUCTURE • Each feature has it’s own step-definition file • Each step has it’s own implementation
  • 6. WHAT CUCUMBER TUTORIALS SAY https://cucumber.io/docs/gherkin/step-organization/
  • 8. FIRST STEPS TO SAVE PROJECT • 1 actions file and one verifications file
  • 10. REPORTS REVIEW No reporting Main problem of testing - its absence
  • 12. IMPLEMENTATIONS OF CUCUMBER STEPS • Some steps were not implemented • Some functions were overcomplicated
  • 13. REPLACE REGEXP WITH CUCUMBER EXPRESSIONS • Parameter types - https://cucumber.io/docs/cucumber/cucumber-expressions/
  • 14. IMPLEMENT YOUR OWN TYPES {url} defineParameterType({ name: 'url', transformer(string) { if (string.indexOf('http') === 0) { return string; } return object.urls[string][environment]; } }); urls: { MAIN_URL: { DEV: "https://test.com", LOCAL: "http://localhost:3000" }, API: { DEV: "https://test.com/#/api", LOCAL: "http://localhost:3000#/api" },
  • 15. IMPLEMENT YOUR OWN TYPES {user} defineParameterType({ name: 'user', transformer(role) { return object.users[role][environment]; } }); users: { USER: { DEV: { login: "test", password: "test" }, PROD: { login: "user_test@test.com", password: "1234" } }, ADMIN: { DEV: { login: "admin", password: "admin" }, PROD: { login: "admin_test@test.com", password: "123456" } } }
  • 16. IMPLEMENT YOUR OWN TYPES In *.feature file User logs in as "USER" on "MAIN” User logs in as "ADMIN" on "API" users: { USER: { DEV: { login: "test", password: "test" }, …… ADMIN: { DEV: { login: "admin", password: "admin" }, ____________________________ urls: { MAIN: { DEV: "http://juliemr.github.io/protractor-demo/", …….. API: { DEV: "http://juliemr.github.io/protractor-demo/api", In conf.js params: { timeout: 3000, env: process.env.TEST_ENV || 'LOCAL', }, process.env.TEST_ENV = DEV
  • 17. SETUP JENKINS JOB #!/usr/bin/env bash # Use this script to run tests npm i npm run webdriver & # Wait for port 5555 to be listening connections chmod +x wait-for-it.sh && ./wait-for-it.sh -t 60 127.0.0.1:5555 -- echo "driver is up" npm run test-jenkins
  • 19. LOCALIZATION TESTING • Parameter type to check text depending of specified language defineParameterType({ name: 'text', transformer: function (s) { if (s.indexOf(':') !== -1) { let dataArray = s.split(':'); let page = dataArray[0]; let textToVerify = dataArray[1]; return text[page][textToVerify][language]; } return s; } }); mainPage: { pageTitle: { ENG: "Wikipedia, the free encyclopedia", RU: "Википедия — свободная энциклопедия" ……….. WIKI: { DEV:{ RU: "https://ru.wikipedia.org/", ENG: "https://en.wikipedia.org/" }, }, params: { env: process.env.TEST_ENV || 'DEV', lan: process.env.TEST_LAN || 'ENG' },
  • 21. PARAMETER TYPES WITH REGEXP defineParameterType({ name: 'text', transformer: function (s) { if (s.indexOf('REGEXP:') !== -1) { s = s.split('REGEXP:')[1]; let dataArray = s.split(':'); let page = dataArray[0]; let textToVerify = dataArray[1]; return new RegExp(text[page][textToVerify][language]); } } }); todayText: { ENG: "single's", RU: "(англ.)русск.," } Then Article "wikiPage|todayText" with text "REGEXP:mainPage:todayText" is displayed And Article "wikiPage|todayText" with text "mainPage:todayText" is displayed
  • 22. SEVERAL MORE IMPROVEMENTS 1. MULTIPLE BROWSERS 2. REUSING THE BROWSER WINDOW 3. TIMEOUTS 4. ATTACHMENTS
  • 23. SLACK FOR FAST REPORTING
  • 24. DO BETTER ON NEW PROJECTS
  • 25. DO BETTER ON NEW PROJECTS • Move common steps, helpers, hooks, configurations to the library • Work with API for preconditions login: async (host, username, password) => { let loginRequest = host + "/login"; let data = {"username": username, "password": password}; let headers = new Map(); headers.set("accept", "application/json"); headers.set("Content-Type", "application/json"); const res = await api.getResponseHeaders("POST", loginRequest, JSON.stringify(data), headers); const token = await res['authorization']; return await global.uniqueMap[token] = token; }, await userApi.login(host, user.login, user.password); When('{user} uploads file to server {landing-url}', async function (user, host) { let token = global.uniqueMap[token]; .......... }
  • 26. REUSE DATA WITHIN SESSION let response = await apiHelper.sendRequest("GET", url, '', headers); return browser.getSession().then(session => { let body = JSON.parse(response.body); let coordinates = body['coord']; let lat = coordinates['lat']; let lon = coordinates['lon']; global.uniqueMap[`${session['id_']}lat`] =lat; global.uniqueMap[`${session['id_']}lon`] =lon; }); return browser.getSession().then(session => { let lat = global.uniqueMap[`${session['id_']}lat`]; let lon = global.uniqueMap[`${session['id_']}lon`]; let url = string+'/weather?lat='+lat+'&lon='+lon let headers = new Map(); headers.set("accept", "application/json"); return apiHelper.sendRequest("GET", url, '', headers).then(function (response) { …………….. }) {"b546863e5dc9ea38992a5c5d99570efflat":51.51,"b546863e5dc9ea38992a5c5d99570efflon":-0.13}
  • 28. WORK WITH FILES IN HEADLESS MODE Before(function () { return browser.getCapabilities().then(caps => { return browser.getProcessedConfig().then((config) => { if (caps.get('browserName') === 'chrome') { return browser.getSession().then(function (session) { const params = { cmd: 'Page.setDownloadBehavior', params: {behavior: 'allow', downloadPath: browser.params.basePath} }; return endpointHelper.sendRequest('POST', `${config.seleniumAddress}/session/${session.id_}/chromium/send_command`, JSON.stringify(params)); }); } });
  • 29. WORK WITH EXCEL FILES Then('User verifies that file {string} is downloaded', (fileName) => { const filePath = browser.params.basePath + fileSep + fileName; return browser.wait(function () { return fs.existsSync(filePath); }, 30000, "Wait for '" + filePath + "' to be downloaded").then(function () { return true; }); });
  • 30. VERIFY FILE BY HASH • Navigate to https://md5file.com/calculator • Upload a file that you want to use as template • Copy calculated value for hash type SHA-1 and paste it into Then('User verify downloaded file {text} hash is equal to {hash}', function (fileName, hash) { return expect(fileHelper.getFileHash(fileName)).to.eventually.equal(hash); }); Then User verify downloaded file "Test.xlsx" hash is equal to "HASH:fileHash” hashes: { fileHash: 'e2c39165ebd60772062684d218259370c739b062', }