QA Fest 2017. Игорь Любин. Примеры ускорения автотестов

Q
Automation tests accelerating examples
Indonesia PhilippinesMalaysia ThailandSingapore Vietnam
Igor Lyubin
1
Automation tests accelerating examples
Indonesia PhilippinesMalaysia ThailandSingapore Vietnam
Igor Lyubin
1
About me
2
# Igor Lyubin
# PhD in Physics
# In QA since 2007
# Senior QA in Lazada
# http://blog.auto-testing.ru/post-550
Lazada
3
# Founded in 2012
# Biggest e-commerce in Asia
# 6 countries
# 650M users
# 40M products
# 1,2M products per day
Lazada
4
# 4 TechHub: VN, SG, TH, RU
# 600 IT engineers
# GoLang, PHP, Python
# Docker, Kubernetes
# https://www.slideshare.net/VLDCORP/kubernetes-76514226
My project
5
# Order API
# 1,5K tests
# Releases every day
# 2 showroom -> 6 staging -> live
# Testing should be fast < 10 minutes
Tests accelerating
6
# Precondition
# Prepare your stuff before
# Speed vs Coverage
# Get more resources
# Make slow fast
# UI Testing
# Hand Helper
# https://www.slideshare.net/alimenkou/how-to-make-your-functional-tests-really-quick
# https://www.slideshare.net/VLDCORP/sqa15 - Badoo
Precondition
7
Set the goal!
8
# Stay in plank while regression testing go
Fix flaky tests
9
# https://wiki.jenkins.io/display/JENKINS/Flaky+Test+Handler+Plugin
# https://www.joecolantonio.com/2015/12/21/top-10-reasons-for-flaky-automated-tests
py.test –-count=100 tests/
Prepare your
stuff before
10
?
11
def test_ok_filter_return_orders_by_ra_number(self):
return_order = db.get_random_return_orders()
ra_number = return_order['ra_number']
...
def test_ok_filter_return_orders_with_return_date(self):
return_order = db.get_random_return_orders()
date = return_order['return_date']
...
Cache data via session scope
12
def test_ok_filter_return_orders_by_ra_number(self):
return_order = db.get_random_return_orders()
ra_number = return_order['ra_number']
...
@pytest.fixture(scope='session')
def return_orders():
return db.get_return_orders(100)
@pytest.fixture
def random_return_order(return_orders):
return random.choice(return_orders)
def test_ok_filter_return_orders_by_ra_number(self, random_return_order):
ra_number = random_return_order['ra_number']
...
Define fixtures for readonly tests
13
# For readonly tests: statistics, filters, get
@pytest.fixture(scope='session')
def session_order():
return create_order()
# For action tests: return order, cancel order
@pytest.fixture
def order():
return create_order()
QA API
14
Coverage vs
Speed
15
?
@pytest.mark.parametrize('status', ['active', 'inactive', 'deleted'])
def test_ok_get_payment_method_by_status(self, status):
response = api.get_payment_method_by_status(status)
...
16
List to random
@pytest.mark.parametrize('status', ['active', 'inactive', 'deleted'])
def test_ok_get_payment_method_by_status(self, status):
response = api.get_payment_method_by_status(status)
...
statuses = ['active', 'inactive', 'deleted']
def test_ok_get_payment_method_by_status(self):
status = random.choice(statuses)
response = api.get_payment_method_by_status(status)
...
17
Split tests on groups
18
# 1 priority – killer feature
# 2 priority - good coverage
# 3 priority – work and ok
?
19
class TestGetCancelOrderQuestions:
def test_ok_get_questions(self):
api.get_cancel_order_questions()
class TestCreateCancelOrderQuestion:
def test_ok_create_question(self, request):
question = api.set_cancel_order_question(request)
questions = api.get_cancel_order_questions()
assert_that(questions[-1], equal_to(request))
...
Combine getter + setter as feature
20
class TestGetCancelOrderQuestions:
def test_ok_list_of_questions(self):
api.get_cancel_order_questions()
class TestCreateCancelOrderQuestion:
def test_ok_create_question(self, request):
question = api.set_cancel_order_question(request)
questions = api.get_cancel_order_questions()
assert_that(questions[-1], equal_to(request))
...
?
21
def test_ok_create_return_order(self, request):
response = api.create_return_order(request)
data = api.get_return_order_by_id(response.id_return_order)
assert_that(data, equal_to(request))
def test_400_create_return_order_twice(self, request):
api.create_return_order(request)
response = api.create_return_order(request)
assert_that(response.status_code, equal_to(400))
Combine ok + twice
22
def test_ok_create_return_order(self, request):
response = api.create_return_order(request)
data = api.get_return_order_by_id(response.id_return_order)
assert_that(data, equal_to(request))
def test_400_create_return_order_twice(self, request):
api.create_return_order(request)
response = api.create_return_order(request)
assert_that(response.status_code, equal_to(400))
Get more
resources
23
Parallelism by classes
24
# Nunit:
[assembly: Parallelizable(ParallelScope.Fixtures)]
# pytest-xdist 1.20:
# https://github.com/pytest-dev/pytest-xdist/pull/191
py.test -v --dist=loadscope
Parallelization on CI
25
Make slow fast
26
Mock
27
@pytest.fixture(scope='session')
def hello_pay_mock():
create_hello_pay_mock()
use_hello_pay_mock()
def test_ok_make_payment_with_hello_pay(self, hello_pay_mock):
...
# http://www.mbtest.org - mountebank
# https://github.com/aholyoke/mountebank-python
Response time SLA
28
@sla(300)
def order_items_by_id(json):
return post('order-items/by-id', json)
@sla(500)
def order_statistics_by_ip(json):
return post('order-statistics/by-ip', json)
# utils/measure_time.py
def sla(milliseconds):
def func_decorator(func):
def func_wrapper(*args):
r = measure_time(lambda: func(*args))
assert_that(r.time, less_than(milliseconds)
return r.result
return func_wrapper
return func_decorator
DB queries vs API requests
29
def test_ok_create_cancel_order_reason(self, request):
response = api.create_cancel_order_reason(request)
data = db.get_cancel_order_reason_by_id(response.id)
assert_that(response, equal_to(data))
def test_ok_create_cancel_order_reason(self, request):
response = api.create_cancel_order_reason(request)
data = api.get_cancel_order_reason_by_id(response.id)
assert_that(response, equal_to(data))
UI Testing
30
Only functional tests
31
# Create
# Read
# Update
# Delete
Direct navigation
32
def test_ok_create_cancel_order_reason(self, reason_data):
app.create_cancel_order_reason(reason_data)
reason = app.get_cancel_order_reason_by_name(reason_data.name)
assert_that(reason, equal_to(reason_data))
def create_create_cancel_order_reason(reason_data):
open_cancel_order_reason_page()
...
Direct asserts in api
33
def test_ok_create_cancel_order_reason(self, reason_data):
app.create_cancel_order_reason(reason_data)
reason = app.get_cancel_order_reason_by_name(reason_data.name)
assert_that(reason, equal_to(reason_data))
def test_ok_create_cancel_order_reason(self, reason_data):
app.create_cancel_order_reason(reason_data)
reason = api.get_cancel_order_reason_by_name(reason_data.name)
assert_that(reason, equal_to(reason_data))
?
34
driver.find_element_by_xpath('//*[contains(@class, "header__links-bar")]')
?
35
driver.find_element_by_xpath('//*[contains(@class, "header__links-bar")]')
driver.find_element_by_xpath('//div[contains(@class, "header__links-bar")]')
Do not use x-path locators
36
driver.find_element_by_xpath('//*[contains(@class, "header__links-bar")]')
driver.find_element_by_xpath('//div[contains(@class, "header__links-bar")]')
driver.find_element_by_id('links-bar-id')
Hand Helper
37
HandHelper
38# https://www.youtube.com/watch?v=Pbe5fK8ksEI
igor.lyubin@lazada.com
https://goo.gl/p17WQF
39
1 of 39

Recommended

WinAppDriver - Windows Store Apps Test Automation by
WinAppDriver - Windows Store Apps Test AutomationWinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test AutomationJeremy Kao
3.3K views31 slides
Test Automation and Innovation with Open Source Tools by
Test Automation and Innovation with Open Source ToolsTest Automation and Innovation with Open Source Tools
Test Automation and Innovation with Open Source ToolsMichael Palotas
1.3K views18 slides
WinAppDriver Development by
WinAppDriver DevelopmentWinAppDriver Development
WinAppDriver DevelopmentJeremy Kao
2K views14 slides
Breaking free from static abuse in test automation frameworks and using Sprin... by
Breaking free from static abuse in test automation frameworks and using Sprin...Breaking free from static abuse in test automation frameworks and using Sprin...
Breaking free from static abuse in test automation frameworks and using Sprin...Abhijeet Vaikar
508 views35 slides
UI Testing Best Practices - An Expected Journey by
UI Testing Best Practices - An Expected JourneyUI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected JourneyOren Farhi
5.1K views45 slides
Automation - web testing with selenium by
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
1.2K views44 slides

More Related Content

Similar to QA Fest 2017. Игорь Любин. Примеры ускорения автотестов

Practical Celery by
Practical CeleryPractical Celery
Practical CeleryCameron Maske
5.6K views84 slides
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ... by
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...Learnosity
655 views45 slides
Angular Intermediate by
Angular IntermediateAngular Intermediate
Angular IntermediateLinkMe Srl
1.3K views96 slides
Unit tests in node.js by
Unit tests in node.jsUnit tests in node.js
Unit tests in node.jsRotem Tamir
873 views16 slides
Multiplication and division of calabash tests by
Multiplication and division of calabash testsMultiplication and division of calabash tests
Multiplication and division of calabash testsRajdeep Varma
435 views33 slides
Apigility & Restfull APIs by
Apigility & Restfull APIsApigility & Restfull APIs
Apigility & Restfull APIsYonni Mendes
1.7K views22 slides

Similar to QA Fest 2017. Игорь Любин. Примеры ускорения автотестов(20)

Educate 2017: Customizing Assessments: Why extending the APIs is easier than ... by Learnosity
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...
Educate 2017: Customizing Assessments: Why extending the APIs is easier than ...
Learnosity655 views
Angular Intermediate by LinkMe Srl
Angular IntermediateAngular Intermediate
Angular Intermediate
LinkMe Srl1.3K views
Unit tests in node.js by Rotem Tamir
Unit tests in node.jsUnit tests in node.js
Unit tests in node.js
Rotem Tamir873 views
Multiplication and division of calabash tests by Rajdeep Varma
Multiplication and division of calabash testsMultiplication and division of calabash tests
Multiplication and division of calabash tests
Rajdeep Varma435 views
Apigility & Restfull APIs by Yonni Mendes
Apigility & Restfull APIsApigility & Restfull APIs
Apigility & Restfull APIs
Yonni Mendes1.7K views
JCD 2013 OCM Java Developer by 益裕 張
JCD 2013 OCM Java DeveloperJCD 2013 OCM Java Developer
JCD 2013 OCM Java Developer
益裕 張470 views
OCM Java 開發人員認證與設計模式 by CodeData
OCM Java 開發人員認證與設計模式OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式
CodeData 2.1K views
Django’s nasal passage by Erik Rose
Django’s nasal passageDjango’s nasal passage
Django’s nasal passage
Erik Rose6.5K views
Using Task Queues and D3.js to build an analytics product on App Engine by River of Talent
Using Task Queues and D3.js to build an analytics product on App EngineUsing Task Queues and D3.js to build an analytics product on App Engine
Using Task Queues and D3.js to build an analytics product on App Engine
River of Talent3.1K views
Hitchhiker's guide to Functional Testing by Wiebe Elsinga
Hitchhiker's guide to Functional TestingHitchhiker's guide to Functional Testing
Hitchhiker's guide to Functional Testing
Wiebe Elsinga934 views
Useful practices of creation automatic tests by using cucumber jvm by Anton Shapin
Useful practices of creation automatic tests by using cucumber jvmUseful practices of creation automatic tests by using cucumber jvm
Useful practices of creation automatic tests by using cucumber jvm
Anton Shapin793 views
Unit testing with Spock Framework by Eugene Dvorkin
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock Framework
Eugene Dvorkin6.7K views
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016 by Dusan Lukic
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic576 views
Seven Peaks Speaks - Compose Screenshot Testing Made Easy by Seven Peaks Speaks
Seven Peaks Speaks - Compose Screenshot Testing Made EasySeven Peaks Speaks - Compose Screenshot Testing Made Easy
Seven Peaks Speaks - Compose Screenshot Testing Made Easy

More from QAFest

QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин by
QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилинQA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин
QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилинQAFest
979 views44 slides
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future by
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The FutureQA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The FutureQAFest
931 views44 slides
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe... by
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...QAFest
322 views131 slides
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и... by
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...QAFest
336 views92 slides
QA Fest 2019. Никита Галкин. Как зарабатывать больше by
QA Fest 2019. Никита Галкин. Как зарабатывать большеQA Fest 2019. Никита Галкин. Как зарабатывать больше
QA Fest 2019. Никита Галкин. Как зарабатывать большеQAFest
389 views40 slides
QA Fest 2019. Сергей Пирогов. Why everything is spoiled by
QA Fest 2019. Сергей Пирогов. Why everything is spoiledQA Fest 2019. Сергей Пирогов. Why everything is spoiled
QA Fest 2019. Сергей Пирогов. Why everything is spoiledQAFest
342 views33 slides

More from QAFest(20)

QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин by QAFest
QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилинQA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин
QA Fest 2019. Сергій Короленко. Топ веб вразливостей за 40 хвилин
QAFest979 views
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future by QAFest
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The FutureQA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future
QA Fest 2019. Анна Чернышова. Self-healing test automation 2.0. The Future
QAFest931 views
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe... by QAFest
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...
QA Fest 2019. Doug Sillars. It's just too Slow: Testing Mobile application pe...
QAFest322 views
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и... by QAFest
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...
QA Fest 2019. Катерина Спринсян. Параллельное покрытие автотестами и другие и...
QAFest336 views
QA Fest 2019. Никита Галкин. Как зарабатывать больше by QAFest
QA Fest 2019. Никита Галкин. Как зарабатывать большеQA Fest 2019. Никита Галкин. Как зарабатывать больше
QA Fest 2019. Никита Галкин. Как зарабатывать больше
QAFest389 views
QA Fest 2019. Сергей Пирогов. Why everything is spoiled by QAFest
QA Fest 2019. Сергей Пирогов. Why everything is spoiledQA Fest 2019. Сергей Пирогов. Why everything is spoiled
QA Fest 2019. Сергей Пирогов. Why everything is spoiled
QAFest342 views
QA Fest 2019. Сергей Новик. Между мотивацией и выгоранием by QAFest
QA Fest 2019. Сергей Новик. Между мотивацией и выгораниемQA Fest 2019. Сергей Новик. Между мотивацией и выгоранием
QA Fest 2019. Сергей Новик. Между мотивацией и выгоранием
QAFest249 views
QA Fest 2019. Владимир Никонов. Код Шредингера или зачем и как мы тестируем н... by QAFest
QA Fest 2019. Владимир Никонов. Код Шредингера или зачем и как мы тестируем н...QA Fest 2019. Владимир Никонов. Код Шредингера или зачем и как мы тестируем н...
QA Fest 2019. Владимир Никонов. Код Шредингера или зачем и как мы тестируем н...
QAFest338 views
QA Fest 2019. Владимир Трандафилов. GUI automation of WEB application with SV... by QAFest
QA Fest 2019. Владимир Трандафилов. GUI automation of WEB application with SV...QA Fest 2019. Владимир Трандафилов. GUI automation of WEB application with SV...
QA Fest 2019. Владимир Трандафилов. GUI automation of WEB application with SV...
QAFest227 views
QA Fest 2019. Иван Крутов. Bulletproof Selenium Cluster by QAFest
QA Fest 2019. Иван Крутов. Bulletproof Selenium ClusterQA Fest 2019. Иван Крутов. Bulletproof Selenium Cluster
QA Fest 2019. Иван Крутов. Bulletproof Selenium Cluster
QAFest282 views
QA Fest 2019. Николай Мижигурский. Миссия /*не*/выполнима: гуманитарий собесе... by QAFest
QA Fest 2019. Николай Мижигурский. Миссия /*не*/выполнима: гуманитарий собесе...QA Fest 2019. Николай Мижигурский. Миссия /*не*/выполнима: гуманитарий собесе...
QA Fest 2019. Николай Мижигурский. Миссия /*не*/выполнима: гуманитарий собесе...
QAFest251 views
QA Fest 2019. Володимир Стиран. Чим раніше – тим вигідніше, але ніколи не піз... by QAFest
QA Fest 2019. Володимир Стиран. Чим раніше – тим вигідніше, але ніколи не піз...QA Fest 2019. Володимир Стиран. Чим раніше – тим вигідніше, але ніколи не піз...
QA Fest 2019. Володимир Стиран. Чим раніше – тим вигідніше, але ніколи не піз...
QAFest301 views
QA Fest 2019. Дмитрий Прокопук. Mocks and network tricks in UI automation by QAFest
QA Fest 2019. Дмитрий Прокопук. Mocks and network tricks in UI automationQA Fest 2019. Дмитрий Прокопук. Mocks and network tricks in UI automation
QA Fest 2019. Дмитрий Прокопук. Mocks and network tricks in UI automation
QAFest225 views
QA Fest 2019. Екатерина Дядечко. Тестирование медицинского софта — вызовы и в... by QAFest
QA Fest 2019. Екатерина Дядечко. Тестирование медицинского софта — вызовы и в...QA Fest 2019. Екатерина Дядечко. Тестирование медицинского софта — вызовы и в...
QA Fest 2019. Екатерина Дядечко. Тестирование медицинского софта — вызовы и в...
QAFest243 views
QA Fest 2019. Катерина Черникова. Tune your P’s: the pop-art of keeping testa... by QAFest
QA Fest 2019. Катерина Черникова. Tune your P’s: the pop-art of keeping testa...QA Fest 2019. Катерина Черникова. Tune your P’s: the pop-art of keeping testa...
QA Fest 2019. Катерина Черникова. Tune your P’s: the pop-art of keeping testa...
QAFest376 views
QA Fest 2019. Алиса Бойко. Какнезапутаться в коммуникативных сетях IT by QAFest
QA Fest 2019. Алиса Бойко. Какнезапутаться в коммуникативных сетях ITQA Fest 2019. Алиса Бойко. Какнезапутаться в коммуникативных сетях IT
QA Fest 2019. Алиса Бойко. Какнезапутаться в коммуникативных сетях IT
QAFest209 views
QA Fest 2019. Святослав Логин. Как найти уязвимости в мобильном приложении by QAFest
QA Fest 2019. Святослав Логин. Как найти уязвимости в мобильном приложенииQA Fest 2019. Святослав Логин. Как найти уязвимости в мобильном приложении
QA Fest 2019. Святослав Логин. Как найти уязвимости в мобильном приложении
QAFest607 views
QA Fest 2019. Катерина Шепелєва та Інна Оснач. Що українцям потрібно знати пр... by QAFest
QA Fest 2019. Катерина Шепелєва та Інна Оснач. Що українцям потрібно знати пр...QA Fest 2019. Катерина Шепелєва та Інна Оснач. Що українцям потрібно знати пр...
QA Fest 2019. Катерина Шепелєва та Інна Оснач. Що українцям потрібно знати пр...
QAFest321 views
QA Fest 2019. Антон Серпутько. Нагрузочное тестирование распределенных асинхр... by QAFest
QA Fest 2019. Антон Серпутько. Нагрузочное тестирование распределенных асинхр...QA Fest 2019. Антон Серпутько. Нагрузочное тестирование распределенных асинхр...
QA Fest 2019. Антон Серпутько. Нагрузочное тестирование распределенных асинхр...
QAFest296 views
QA Fest 2019. Петр Тарасенко. QA Hackathon - The Cookbook 22 by QAFest
QA Fest 2019. Петр Тарасенко. QA Hackathon - The Cookbook 22QA Fest 2019. Петр Тарасенко. QA Hackathon - The Cookbook 22
QA Fest 2019. Петр Тарасенко. QA Hackathon - The Cookbook 22
QAFest164 views

Recently uploaded

Women from Hackney’s History: Stoke Newington by Sue Doe by
Women from Hackney’s History: Stoke Newington by Sue DoeWomen from Hackney’s History: Stoke Newington by Sue Doe
Women from Hackney’s History: Stoke Newington by Sue DoeHistory of Stoke Newington
157 views21 slides
How to empty an One2many field in Odoo by
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in OdooCeline George
72 views8 slides
AUDIENCE - BANDURA.pptx by
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptxiammrhaywood
89 views44 slides
UNIDAD 3 6º C.MEDIO.pptx by
UNIDAD 3 6º C.MEDIO.pptxUNIDAD 3 6º C.MEDIO.pptx
UNIDAD 3 6º C.MEDIO.pptxMarcosRodriguezUcedo
124 views32 slides
GSoC 2024 by
GSoC 2024GSoC 2024
GSoC 2024DeveloperStudentClub10
81 views15 slides
ICS3211_lecture 08_2023.pdf by
ICS3211_lecture 08_2023.pdfICS3211_lecture 08_2023.pdf
ICS3211_lecture 08_2023.pdfVanessa Camilleri
187 views30 slides

Recently uploaded(20)

How to empty an One2many field in Odoo by Celine George
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in Odoo
Celine George72 views
AUDIENCE - BANDURA.pptx by iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood89 views
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx by Ms. Pooja Bhandare
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
The basics - information, data, technology and systems.pdf by JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1126 views
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively by PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 598 views
The Accursed House by Émile Gaboriau by DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta212 views
Structure and Functions of Cell.pdf by Nithya Murugan
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdf
Nithya Murugan701 views
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... by Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
Ch. 8 Political Party and Party System.pptx by Rommel Regala
Ch. 8 Political Party and Party System.pptxCh. 8 Political Party and Party System.pptx
Ch. 8 Political Party and Party System.pptx
Rommel Regala53 views
Drama KS5 Breakdown by WestHatch
Drama KS5 BreakdownDrama KS5 Breakdown
Drama KS5 Breakdown
WestHatch87 views
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx by ISSIP
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptxEIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
EIT-Digital_Spohrer_AI_Intro 20231128 v1.pptx
ISSIP379 views
Sociology KS5 by WestHatch
Sociology KS5Sociology KS5
Sociology KS5
WestHatch76 views
AI Tools for Business and Startups by Svetlin Nakov
AI Tools for Business and StartupsAI Tools for Business and Startups
AI Tools for Business and Startups
Svetlin Nakov111 views
Monthly Information Session for MV Asterix (November) by Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC58 views

QA Fest 2017. Игорь Любин. Примеры ускорения автотестов

  • 1. Automation tests accelerating examples Indonesia PhilippinesMalaysia ThailandSingapore Vietnam Igor Lyubin 1 Automation tests accelerating examples Indonesia PhilippinesMalaysia ThailandSingapore Vietnam Igor Lyubin 1
  • 2. About me 2 # Igor Lyubin # PhD in Physics # In QA since 2007 # Senior QA in Lazada # http://blog.auto-testing.ru/post-550
  • 3. Lazada 3 # Founded in 2012 # Biggest e-commerce in Asia # 6 countries # 650M users # 40M products # 1,2M products per day
  • 4. Lazada 4 # 4 TechHub: VN, SG, TH, RU # 600 IT engineers # GoLang, PHP, Python # Docker, Kubernetes # https://www.slideshare.net/VLDCORP/kubernetes-76514226
  • 5. My project 5 # Order API # 1,5K tests # Releases every day # 2 showroom -> 6 staging -> live # Testing should be fast < 10 minutes
  • 6. Tests accelerating 6 # Precondition # Prepare your stuff before # Speed vs Coverage # Get more resources # Make slow fast # UI Testing # Hand Helper # https://www.slideshare.net/alimenkou/how-to-make-your-functional-tests-really-quick # https://www.slideshare.net/VLDCORP/sqa15 - Badoo
  • 8. Set the goal! 8 # Stay in plank while regression testing go
  • 9. Fix flaky tests 9 # https://wiki.jenkins.io/display/JENKINS/Flaky+Test+Handler+Plugin # https://www.joecolantonio.com/2015/12/21/top-10-reasons-for-flaky-automated-tests py.test –-count=100 tests/
  • 11. ? 11 def test_ok_filter_return_orders_by_ra_number(self): return_order = db.get_random_return_orders() ra_number = return_order['ra_number'] ... def test_ok_filter_return_orders_with_return_date(self): return_order = db.get_random_return_orders() date = return_order['return_date'] ...
  • 12. Cache data via session scope 12 def test_ok_filter_return_orders_by_ra_number(self): return_order = db.get_random_return_orders() ra_number = return_order['ra_number'] ... @pytest.fixture(scope='session') def return_orders(): return db.get_return_orders(100) @pytest.fixture def random_return_order(return_orders): return random.choice(return_orders) def test_ok_filter_return_orders_by_ra_number(self, random_return_order): ra_number = random_return_order['ra_number'] ...
  • 13. Define fixtures for readonly tests 13 # For readonly tests: statistics, filters, get @pytest.fixture(scope='session') def session_order(): return create_order() # For action tests: return order, cancel order @pytest.fixture def order(): return create_order()
  • 16. ? @pytest.mark.parametrize('status', ['active', 'inactive', 'deleted']) def test_ok_get_payment_method_by_status(self, status): response = api.get_payment_method_by_status(status) ... 16
  • 17. List to random @pytest.mark.parametrize('status', ['active', 'inactive', 'deleted']) def test_ok_get_payment_method_by_status(self, status): response = api.get_payment_method_by_status(status) ... statuses = ['active', 'inactive', 'deleted'] def test_ok_get_payment_method_by_status(self): status = random.choice(statuses) response = api.get_payment_method_by_status(status) ... 17
  • 18. Split tests on groups 18 # 1 priority – killer feature # 2 priority - good coverage # 3 priority – work and ok
  • 19. ? 19 class TestGetCancelOrderQuestions: def test_ok_get_questions(self): api.get_cancel_order_questions() class TestCreateCancelOrderQuestion: def test_ok_create_question(self, request): question = api.set_cancel_order_question(request) questions = api.get_cancel_order_questions() assert_that(questions[-1], equal_to(request)) ...
  • 20. Combine getter + setter as feature 20 class TestGetCancelOrderQuestions: def test_ok_list_of_questions(self): api.get_cancel_order_questions() class TestCreateCancelOrderQuestion: def test_ok_create_question(self, request): question = api.set_cancel_order_question(request) questions = api.get_cancel_order_questions() assert_that(questions[-1], equal_to(request)) ...
  • 21. ? 21 def test_ok_create_return_order(self, request): response = api.create_return_order(request) data = api.get_return_order_by_id(response.id_return_order) assert_that(data, equal_to(request)) def test_400_create_return_order_twice(self, request): api.create_return_order(request) response = api.create_return_order(request) assert_that(response.status_code, equal_to(400))
  • 22. Combine ok + twice 22 def test_ok_create_return_order(self, request): response = api.create_return_order(request) data = api.get_return_order_by_id(response.id_return_order) assert_that(data, equal_to(request)) def test_400_create_return_order_twice(self, request): api.create_return_order(request) response = api.create_return_order(request) assert_that(response.status_code, equal_to(400))
  • 24. Parallelism by classes 24 # Nunit: [assembly: Parallelizable(ParallelScope.Fixtures)] # pytest-xdist 1.20: # https://github.com/pytest-dev/pytest-xdist/pull/191 py.test -v --dist=loadscope
  • 27. Mock 27 @pytest.fixture(scope='session') def hello_pay_mock(): create_hello_pay_mock() use_hello_pay_mock() def test_ok_make_payment_with_hello_pay(self, hello_pay_mock): ... # http://www.mbtest.org - mountebank # https://github.com/aholyoke/mountebank-python
  • 28. Response time SLA 28 @sla(300) def order_items_by_id(json): return post('order-items/by-id', json) @sla(500) def order_statistics_by_ip(json): return post('order-statistics/by-ip', json) # utils/measure_time.py def sla(milliseconds): def func_decorator(func): def func_wrapper(*args): r = measure_time(lambda: func(*args)) assert_that(r.time, less_than(milliseconds) return r.result return func_wrapper return func_decorator
  • 29. DB queries vs API requests 29 def test_ok_create_cancel_order_reason(self, request): response = api.create_cancel_order_reason(request) data = db.get_cancel_order_reason_by_id(response.id) assert_that(response, equal_to(data)) def test_ok_create_cancel_order_reason(self, request): response = api.create_cancel_order_reason(request) data = api.get_cancel_order_reason_by_id(response.id) assert_that(response, equal_to(data))
  • 31. Only functional tests 31 # Create # Read # Update # Delete
  • 32. Direct navigation 32 def test_ok_create_cancel_order_reason(self, reason_data): app.create_cancel_order_reason(reason_data) reason = app.get_cancel_order_reason_by_name(reason_data.name) assert_that(reason, equal_to(reason_data)) def create_create_cancel_order_reason(reason_data): open_cancel_order_reason_page() ...
  • 33. Direct asserts in api 33 def test_ok_create_cancel_order_reason(self, reason_data): app.create_cancel_order_reason(reason_data) reason = app.get_cancel_order_reason_by_name(reason_data.name) assert_that(reason, equal_to(reason_data)) def test_ok_create_cancel_order_reason(self, reason_data): app.create_cancel_order_reason(reason_data) reason = api.get_cancel_order_reason_by_name(reason_data.name) assert_that(reason, equal_to(reason_data))
  • 36. Do not use x-path locators 36 driver.find_element_by_xpath('//*[contains(@class, "header__links-bar")]') driver.find_element_by_xpath('//div[contains(@class, "header__links-bar")]') driver.find_element_by_id('links-bar-id')