144
Test Automation In Python

Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

  • Upload
    others

  • View
    33

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Automation In Python

Page 2: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Kyle McEvoy

@_kmce

Director of QA

Page 3: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Kyle McEvoy

@_kmce

Director of QA

First conf talk! Thanks NTD!

Page 4: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

We’re hiring!fanduel.com/careers

Page 5: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

What Python has to offer for test automation

Page 6: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

What Python has to offer for test automation

General use case examples

Page 7: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

What Python has to offer for test automation

General use case examples

Lessons learned in test automation

Page 8: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 9: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 10: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

Page 11: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall

Page 12: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Page 13: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Your skills

Page 14: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Your skillsSkills of team

Page 15: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Your skillsSkills of team

Test co-location

Page 16: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Your skillsSkills of team

Test co-location

Available packages

Page 17: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Your skillsSkills of team

Test co-location

External support

Available packages

Page 18: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Why Python? Why not X?

● No language is truly ‘better’ overall● It’s all about context!

Your skillsSkills of team

Test co-location

External support

Available packages Design principles

Page 19: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 20: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 21: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 22: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 23: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 24: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 25: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 26: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● Lower barrier for entry● Open source● Scripted language● Platform independent● Extensive standard library● Extensive community packages (PyPI)● Vibrant and supportive community

Python

Page 27: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Java

Python

Page 28: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Java

Python1 < 5

Page 29: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 30: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Browsers

Page 31: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

BrowsersNative Apps

Page 32: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

BrowsersNative Apps

APIs

Page 33: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

BrowsersNative Apps

APIsDistribution/Concurrency

Page 34: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

BrowsersNative Apps

APIsDistribution/Concurrency

BDD

Page 35: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

BrowsersNative Apps

APIsDistribution/Concurrency

Reporting

BDD

Page 36: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

BrowsersNative Apps

APIsDistribution/Concurrency

Reporting

BDD

Test Framework

Page 37: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Popular test frameworks

● unittest (standard library)

Page 38: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● unittest (standard library)

● Robot Framework

Popular test frameworks

Page 39: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● unittest (standard library)

● Robot Framework

● pytest

Popular test frameworks

Page 40: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● unittest (standard library)

● Robot Framework

● pytest

Popular test frameworks

Page 41: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

● unittest (standard library)

● Robot Framework

● pytest

Popular test frameworks

Page 42: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic JUnit TestFirstJUnit5Tests.java

Page 43: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic pytest Test

test_file_example.py

Page 44: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

JUnit

pytest

Page 45: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic pytest Test

test_file_example.py

Page 46: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic pytest Test

test_file_example.py

Page 47: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic pytest Test

test_file_example.py

“test_”

Page 48: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Installing pytestTerminal

Page 49: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Installing pytestTerminal

Pip Installs Packages

Page 50: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Installing pytest

PyPIYou

Page 51: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Installing pytest

PyPIYou

Page 52: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Installing pytestTerminal

Virtual Environments

Page 53: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Python Virtual Environments

venv venv2 venv3- pytest (3.2.2)

- custom (1.3.1)

- pytest (3.2.2)

- custom (2.0.1)

- pytest (3.5.1)

Project1 Project2 Project3

Page 54: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Python Virtual Environments

wtests ios apienv- pytest (3.2.2)

- custom (1.3.1)

- pytest (3.2.2)

- custom (2.0.1)

- pytest (3.5.1)

WebTests IOSTests APITests

Page 55: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic pytest Test

test_file_example.py

Page 56: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test resultTerminal

Page 57: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Basic pytest Test

test_file_example.py

Page 58: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test resultTerminal

Page 59: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest

● Test auto-discovery

Page 60: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest

● Test auto-discovery● No boilerplate

Page 61: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest

● Test auto-discovery● No boilerplate

● Detailed failure introspection

Page 62: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest

● Test auto-discovery● No boilerplate

● Detailed failure introspection

● Simple modular test fixtures

Page 63: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

VERIFY

Page 64: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

EXERCISE VERIFY

Page 65: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

SETUP EXERCISE VERIFY

Page 66: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

SETUP EXERCISE VERIFY TEARDOWN

Page 67: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

SETUP EXERCISE VERIFY TEARDOWN

Test Function

Page 68: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

SETUP EXERCISE VERIFY TEARDOWN

Test Fixtures

Page 69: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

JUnit fixture exampleFirstJUnit5Tests.java

Page 70: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

JUnit fixture exampleFirstJUnit5Tests.java

Page 71: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest fixture example

test_file_example.py

Page 72: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest fixture example

test_file_example.py

Page 73: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest fixture example

test_file_example.py

Page 74: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Page 75: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case API Test

Page 76: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Methods● Login● Get my username● Give money● Logout

API Test

Page 77: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Methods● Login● Get my username● Give money● Logout

Methods under test● Get my username● Give money

API Test

Page 78: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Methods● Login● Get my username● Give money● Logout

Methods under test● Get my username● Give money

Test Setup● Login

API Test

Page 79: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Methods● Login● Get my username● Give money● Logout

Methods under test● Get my username● Give money

Test Setup● Login

Test Teardown● Logout

API Test

Page 80: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Methods● Login● Get my username● Give money● Logout

Methods under test● Get my username● Give money

Test Setup● Login

Test Teardown● Logout

Already created● API Client SDK● Data models

(e.g. User)● Test user

API Test

Page 81: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_file_example.py

Page 82: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_file_example.py

Page 83: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 84: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 85: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 86: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 87: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 88: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_file_example.pyfixtures

Page 89: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_file_example.pyfixtures

test

Page 90: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_file_example.py

fixtures

test

imports

Page 91: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

conftest.py

test_usernames.py

Page 92: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

conftest.py

test_usernames.py test_credit.py

Page 93: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Methods● Login● Get my username● Give money● Logout

Methods under test● Get my username● Give money

Test Setup● Login

Test Teardown● Logout

Already created● API Client SDK● Data models

(e.g. User)● Test user

API Test

Page 94: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

conftest.py

test_usernames.py test_credit.py

Page 95: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

conftest.py

test_usernames.py test_credit.py

Page 96: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

conftest.py

test_usernames.py test_credit.py

Page 97: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_credit.py

Page 98: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_credit.py

Page 99: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest

● Test auto-discovery● No boilerplate

● Detailed failure introspection

● Simple modular test fixtures

Page 100: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pytest

● Test auto-discovery● No boilerplate

● Detailed failure introspection

● Simple modular test fixtures

● Great plugins & complimentary packages

Page 101: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Popular plugins & packages

● Selenium Python bindings (selenium)● pytest Selenium wrapper (pytest-selenium)● Appium Python bindings (Appium-Python-Client)● Behaviour-Driven Development (pytest-bdd)● Test distribution (pytest-xdist)

Page 102: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Popular plugins & packages

● Selenium Python bindings (selenium)● pytest Selenium wrapper (pytest-selenium)● Appium Python bindings (Appium-Python-Client)● Behaviour-Driven Development (pytest-bdd)● Test distribution (pytest-xdist)

Page 103: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Popular plugins & packages

● Selenium Python bindings (selenium)● pytest Selenium wrapper (pytest-selenium)● Appium Python bindings (Appium-Python-Client)● Behaviour-Driven Development (pytest-bdd)● Test distribution (pytest-xdist)

Page 104: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Popular plugins & packages

● Selenium Python bindings (selenium)● pytest Selenium wrapper (pytest-selenium)● Appium Python bindings (Appium-Python-Client)● Behaviour-Driven Development (pytest-bdd)● Test distribution (pytest-xdist)

Page 105: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Popular plugins & packages

● Selenium Python bindings (selenium)● pytest Selenium wrapper (pytest-selenium)● Appium Python bindings (Appium-Python-Client)● Behaviour-Driven Development (pytest-bdd)● Test distribution (pytest-xdist)

Page 106: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Terminal

Terminal

test_file_example.py

Page 107: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

test_file_example.py

Page 108: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible
Page 109: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

*not a real tw eet

Page 110: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case

Page 111: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case Browser Test

Page 112: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case Browser Test

Page under test● Deposit page

Page 113: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case Browser Test

Page under test● Deposit page

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Page 114: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Use case Browser Test

Page under test● Deposit page

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

Page 115: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

Page 116: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

user fixture

Page 117: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

user fixtureselenium fixture

Page 118: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

user fixtureselenium fixturelogged_in_browser fixture

Page 119: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

user fixtureselenium fixturelogged_in_browser fixturedeposit_page fixture

Page 120: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Test Setup● Create user● Load browser● Login as user● Navigate to

Deposit Page

Test Teardown● Close browser

user fixtureselenium fixturelogged_in_browser fixturedeposit_page fixture

selenium fixture

Page 121: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

pages/deposit_page.py

Page 122: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

conftest.py

Page 123: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

tests/test_deposit_page.py

Page 124: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

tests/test_deposit_page.py

Page 125: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

tests/test_deposit_page.py

Page 126: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

tests/test_deposit_page.py

Page 127: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

decorators.py

Page 128: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

decorators.py

conftest.py

Page 129: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

tests/test_deposit_page.py

Page 130: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

tests/test_deposit_page.py

Page 131: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Client projects

Page 132: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Client projects API projects

Page 133: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Client projects API projects Services Projects

Page 134: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Client projects API projects Services Projects

Page 135: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Client projects API projects Services Projects

Common project

CommonFixtures & helpers

contestsusers

services & more

entriesrewards

Page 136: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Further readingpytest.org (Thank you pytest contributors!)

Page 137: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

Page 138: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

● There are alternatives to ‘pre-production’ automation

Page 139: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

● There are alternatives to ‘pre-production’ automation● Keep it as focused on risk and lightweight as possible

Page 140: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

● There are alternatives to ‘pre-production’ automation● Keep it as focused on risk and lightweight as possible● It’s a cultural challenge as much as it is technical

Page 141: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

● There are alternatives to ‘pre-production’ automation● Keep it as focused on risk and lightweight as possible● It’s a cultural challenge as much as it is technical● Testability can often be underrated

Page 142: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

● There are alternatives to ‘pre-production’ automation● Keep it as focused on risk and lightweight as possible● It’s a cultural challenge as much as it is technical● Testability can often be underrated● Have zero tolerance for test ‘flakiness’

Page 143: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Lessons learned in test automation

● There are alternatives to ‘pre-production’ automation● Keep it as focused on risk and lightweight as possible● It’s a cultural challenge as much as it is technical● Testability can often be underrated● Have zero tolerance for test ‘flakiness’● Peer reviews on tests are invaluable

Page 144: Test Automation In Python - FINAL · Lessons learned in test automation There are alternatives to ‘pre -production’ automation Keep it as focused on risk and lightweight as possible

Thank you!@_kmce