Testing Testing everywhere

51
Testing, testing everywhere! Toni Robres Turón @twiindan

description

Conference given in the PyConES 2014

Transcript of Testing Testing everywhere

Page 1: Testing Testing everywhere

Testing, testing everywhere!

Toni Robres Turón

@twiindan

Page 2: Testing Testing everywhere

{name: Toni Robres}

{role: QA}

Page 3: Testing Testing everywhere
Page 4: Testing Testing everywhere

Sometimes diversity is not good

Page 5: Testing Testing everywhere

Sometimes diversity is not good

Page 6: Testing Testing everywhere

Confrontation

Page 7: Testing Testing everywhere

Which characteristics should have the

perfect testing tool?

Page 8: Testing Testing everywhere
Page 9: Testing Testing everywhere
Page 10: Testing Testing everywhere
Page 11: Testing Testing everywhere
Page 12: Testing Testing everywhere
Page 13: Testing Testing everywhere

Testing Activities

Unit Testing

Acceptance Testing

Web Testing

Performance Testing

Test Definition

Page 14: Testing Testing everywhere

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: Testing Testing everywhere
Page 16: Testing Testing everywhere

EXECUTE THE TESTS

Page 17: Testing Testing everywhere

Coverage

Page 18: Testing Testing everywhere

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: Testing Testing everywhere

Basic usage

Page 20: Testing Testing everywhere

Usage

• Query Parameters defined as Python Dict:

• Custom headers defined as Python Dict

Page 21: Testing Testing everywhere

Usage

Basic authentication

Content body defined as Python Dict

Page 22: Testing Testing everywhere

Usage

• Upload a file:

• Cookies

• Cookies

Page 23: Testing Testing everywhere

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: Testing Testing everywhere

Selenium

• How it works?– Locate the Elements

• By id, CSS, XPATH, name, Class...

– Select Elements• Assert properties

– Interact • Send keys

• Click

Page 25: Testing Testing everywhere

Basic Example

Page 26: Testing Testing everywhere

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: Testing Testing everywhere
Page 28: Testing Testing everywhere
Page 29: Testing Testing everywhere

Web Testing

• What happen with selenium IDE?

Page 30: Testing Testing everywhere

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: Testing Testing everywhere

Config File

Page 32: Testing Testing everywhere

Script File

Page 33: Testing Testing everywhere

Example script File

Page 34: Testing Testing everywhere

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: Testing Testing everywhere

Graphs

Page 36: Testing Testing everywhere

Graphs

Page 37: Testing Testing everywhere

Graphs

Page 38: Testing Testing everywhere

Summarizing

• I can do tests in all Levels:

– Web

– API

– Performance

• What happen with test Definition and test Execution stats?

Page 39: Testing Testing everywhere

Jira / TestLink / IBM

Page 40: Testing Testing everywhere

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: Testing Testing everywhere

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 behaviour

Page 42: Testing Testing everywhere

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: Testing Testing everywhere

Coding example

Page 44: Testing Testing everywhere

Test Runner and report

Page 45: Testing Testing everywhere

ComitéTécnicoVLCTESTING2014

email:[email protected]

WebUsuarios

SMS

WebSoporte

Backend

BBDD

Page 46: Testing Testing everywhere

Que probar y con que?

Page 47: Testing Testing everywhere

Que probar y con que?

• Unit testing all components• Component test:

– Backend Requests– Webs Webdriver mocking the backend– Mobile Appium mocking the backend

• Integration:– Webs and backend– Mobile and backend– Backend with SMS plattform

• E2E

Page 48: Testing Testing everywhere

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 49: Testing Testing everywhere

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 50: Testing Testing everywhere

Result

Page 51: Testing Testing everywhere

Questions?