Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Pytest Fixtures for Specification By Exam...

Avatar for Ted Landis Ted Landis
January 18, 2016

Using Pytest Fixtures for Specification By Example (SBE) Test Automation

Pytest’s incredibly flexible fixtures feature dependency injection and support modular, extendable test design.

By adding the pytest-bdd plugin these fixtures also support high level Cucumber/Gherkin style scenario testing that allow your automated tests to be authored and reviewed by anyone on the product team.

In this talk, we will look at how pytest-bdd and selenium based page objects are being used to automate functional testing of a cloud application.

Presented at a Montréal-Python Meetup.

Avatar for Ted Landis

Ted Landis

January 18, 2016
Tweet

More Decks by Ted Landis

Other Decks in Programming

Transcript

  1. Montréal — Python January 18, 2016 USING PYTEST FIXTURES FOR

    SPECIFICATION BY EXAMPLE (SBE) TEST AUTOMATION MONTRÉAL — PYTHON JANUARY 18, 2016 Pytest’s incredibly flexible fixtures feature dependency injection and support modular, extendable test design. By adding the pytest-bdd plugin these fixtures also support high level Cucumber/Gherkin style scenario testing that allow your automated tests to be authored and reviewed by anyone on the product team. In this talk, we will look at how pytest-bdd and selenium based page objects are being used to automate functional testing of a cloud application.
  2. Montréal — Python January 18, 2016 AGENDA ▪INTRODUCTION ▪WHY TEST

    AUTOMATION? ▪WHY SPECIFICATION BY EXAMPLE (SBE) ? ▪WEB FUNCTIONAL TESTING ▪CODE SAMPLES ▪QUESTIONS?
  3. TED LANDIS ▪Developing software for many years ▪mostly small start-ups

    or as an independent consultant ▪8 years at IBM ▪Python for 10 years ▪Background in Data ▪Introduced to SBE via Ruby on Rails Test Automation Manager, Lightspeed POS
  4. Montréal — Python January 18, 2016 WHY TEST AUTOMATION? ▪

    PROVIDE QUICK VERIFICATION OF FEATURES AND QUALITY ▪ FREE UP QA ANALYSTS TO PERFORM: ▪DIFFICULT TO AUTOMATE TESTS ▪DISCOVERY AND INVESTIGATIONS ▪EXECUTE IN AUTOMATED ENVIRONMENTS ▪CONTINUOUS INTEGRATION (CI) ▪NEW RELIC SYNTHETICS ▪LOAD AND PERFORMANCE TESTING ▪DEVELOPERS CAN TEST EARLY, TEST OFTEN
  5. Montréal — Python January 18, 2016 WHY SBE? ▪ “LIVING”

    EXECUTABLE SPECIFICATION ▪FEATURE ORIENTED (DEFINED USER VALUE) ▪EXAMPLE SCENARIOS ▪UBIQUITOUS LANGUAGE (COMMON TERMINOLOGY) ▪POINT OF SALE DOMAIN LANGUAGE ▪PRICE VS COST ▪TESTS ACCESSIBLE TO ENTIRE PRODUCT TEAM ▪ISN’T THIS JUST BDD?
  6. Montréal — Python January 18, 2016 SEVEN PROCESS PATTERNS GOJKO

    ADZIC - AUTHOR OF SPECIFICATION BY EXAMPLE 1. DERIVING SCOPE FROM GOALS 2.SPECIFYING COLLABORATIVELY 3.ILLUSTRATING SPECIFICATIONS USING EXAMPLES 4.REFINING THE SPECIFICATIONS 5.AUTOMATING VALIDATION WITHOUT CHANGING THE SPECIFICATIONS 6.VALIDATING THE SYSTEM FREQUENTLY 7. EVOLVING LIVING DOCUMENTATION
  7. Montréal — Python January 18, 2016 FUNCTIONAL EXAMPLE SCENARIOS ▪PYTEST

    WITH THE PYTEST-BDD PLUG-IN ▪FEATURE BASED TEST SCENARIOS (ENGLISH/GHERKIN) ▪SHARED STEP DEFINITIONS (PYTHON) ▪FIXTURES! DATA, WEB AND API (PYTHON) ▪PYTEST-BDD GENERATED TEST SCRIPTS ▪WEB - PYTHON AND SELENIUM IN PYTEST ▪API - PYTHON IN PYTEST ▪NEW RELIC - JAVASCRIPT ▪IOS - SWIFT IN XCTEST
  8. Montréal — Python January 18, 2016 Data Scenario Scenario Step

    Definition Web API Web API Web App Step Definition Step Definition Step Definition Step Definition Scenario Data Data
  9. Montréal — Python January 18, 2016 functional data steps web

    sbe data web pages features fields selectors panels whens givens thens
  10. Montréal — Python January 18, 2016 Field Button Field Field

    Label: Field Label: Field Label: Field Label: Field Label: Page Panel Field Field Field Field
  11. Montréal — Python January 18, 2016 MERCI THANK YOU ▪

    QUESTIONS? ▪ USEFUL LINKS: ▪SPECIFICATION BY EXAMPLE ▪PYTEST ▪PYTEST-BDD