One to rule them all
-
Upload
antonio-robres-turon -
Category
Software
-
view
296 -
download
2
description
Transcript of One to rule them all
![Page 1: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/1.jpg)
One testing tool to rule them all
Toni Robres Turón
@twiindan
![Page 2: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/2.jpg)
{name: Toni Robres, role: QA}
![Page 3: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/3.jpg)
![Page 4: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/4.jpg)
Sometimes diversity is not good
![Page 5: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/5.jpg)
Sometimes diversity is not good
![Page 6: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/6.jpg)
Confrontation
![Page 7: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/7.jpg)
Which characteristics should have the
perfect testing tool?
![Page 8: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/8.jpg)
![Page 9: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/9.jpg)
![Page 10: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/10.jpg)
![Page 11: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/11.jpg)
![Page 12: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/12.jpg)
![Page 13: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/13.jpg)
Testing Activities
Unit Testing
Acceptance Testing
Web Testing
Performance Testing
Test Definition
![Page 14: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/14.jpg)
Unit Testing
• Nose
– Extended framework for python unit testing
– Easy to write and run tests
– Provides coverage
– Provides profiler
– Test can be organized
– Include tools for testing
![Page 15: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/15.jpg)
![Page 16: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/16.jpg)
EXECUTE THE TESTS
![Page 17: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/17.jpg)
Coverage
![Page 18: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/18.jpg)
API REST Testing
• Request: HTTP For humans– Library to perform API REST requests
– Easy to use
– Basic and Oauth Authentication
– Cookies support
– Multipart Files Upload
– Session objects
– Verify SSL Certificates
– Proxies
– Can be integrated with nose and lettuce
![Page 19: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/19.jpg)
Basic usage
![Page 20: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/20.jpg)
Usage
• Query Parameters defined as Python Dict:
• Custom headers defined as Python Dict
![Page 21: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/21.jpg)
Usage
Basic authentication
Content body defined as Python Dict
![Page 22: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/22.jpg)
Usage
• Upload a file:
• Cookies
• Cookies
![Page 23: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/23.jpg)
Web Testing
• Selenium
– Most extended library to test Web GUI
– Suport Firefox, Chrome and Internet Explorer
– Can be integrated with nose and lettuce
– Integrated with CI
– Grid support
– Cookies support
![Page 24: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/24.jpg)
Selenium
• How it works?– Locate the Elements
• By id, CSS, XPATH, name, Class...
– Select Elements• Assert properties
– Interact • Send keys
• Click
![Page 25: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/25.jpg)
Basic Example
![Page 26: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/26.jpg)
Page Object Pattern
• Language Neutral Pattern for representing a web page in an Object Oriented manner
• Necessary for survive in Selenium
– Increase maintanability
– Increase readability
– Abstract web page logical from tests
![Page 27: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/27.jpg)
![Page 28: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/28.jpg)
![Page 29: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/29.jpg)
Web Testing
• What happen with selenium IDE?
![Page 30: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/30.jpg)
Perfomance Testing
• MultiMechanize
– Runs concurrent Python scripts to generate load against service
– Reporting as Jmeter compatible
– Easy configuration
– Can reuse Custom Request library
– Multithreading and multiprocessing
– Distributed
![Page 31: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/31.jpg)
Config File
![Page 32: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/32.jpg)
Script File
![Page 33: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/33.jpg)
Example script File
![Page 34: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/34.jpg)
Multi Mechanize Stats
• test summary• transaction timers• custom timers (from instrumented client code)• time-series/interval data• counts• rate/throughput• response times• average, min, max, stdev• percentiles (80th, 90th, 95th)
![Page 35: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/35.jpg)
Graphs
![Page 36: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/36.jpg)
Graphs
![Page 37: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/37.jpg)
Graphs
![Page 38: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/38.jpg)
Summarizing
• I can do tests in all Levels:
– Web
– API
– Performance
• What happen with test Definition and test Execution stats?
![Page 39: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/39.jpg)
Jira
![Page 40: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/40.jpg)
BDD
• Using examples to create a shared understanding and surface uncertainly to deliver software that matters.
• Define the software behaviour:
– Given (Preconditions)
– When (actions)
– Then (Post conditions)
![Page 41: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/41.jpg)
Lettuce
• BDD Tool for Python
• Easy to integrate with tests developed with Request and Webdriver
• Data driven
• Using decorators to execute functions that describes the software behavour
![Page 42: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/42.jpg)
Feature Example
Scenario Outline: Retrieve the geolocation with city name given
Given a <city> nameWhen I request the geoencoding of the cityThen I obtain the <city> name with the <country_code>
Examples:
| city | country_code || Barcelona | ES || Paris | FR || San+Francisco | US |
![Page 43: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/43.jpg)
Coding example
![Page 44: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/44.jpg)
Test Runner and report
![Page 45: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/45.jpg)
Bonus Track
• Mocks!
– For developers
• Mockito
• Unittest.mock
– Mocking API
• Bottle
• Base HTTP
![Page 46: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/46.jpg)
Bonus Track
• What happen if my component has different interface than API REST?
– All the components always have an input
– For example
• Rabbit Pika, Kombu
• MongoDB Pymongo
• Redis Python Redis client
• MySQL sqlite, sqlalchemy
![Page 47: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/47.jpg)
Overview
• Using Python for all testing activities
– Easy to integrate
– Can reuse common libraries
– Only needs learn one tool
– Collaboration between development and testing
– Community
![Page 48: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/48.jpg)
Result
![Page 49: One to rule them all](https://reader033.fdocuments.in/reader033/viewer/2022052508/559af3f91a28abad708b478f/html5/thumbnails/49.jpg)
Questions?