Top Banner
One testing tool to rule them all Toni Robres Turón @twiindan
49

One to rule them all

Jul 07, 2015

Download

Software

Use Python to automate in all levels including test definition
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: One to rule them all

One testing tool to rule them all

Toni Robres Turón

@twiindan

Page 2: One to rule them all

{name: Toni Robres, role: QA}

Page 3: One to rule them all
Page 4: One to rule them all

Sometimes diversity is not good

Page 5: One to rule them all

Sometimes diversity is not good

Page 6: One to rule them all

Confrontation

Page 7: One to rule them all

Which characteristics should have the

perfect testing tool?

Page 8: One to rule them all
Page 9: One to rule them all
Page 10: One to rule them all
Page 11: One to rule them all
Page 12: One to rule them all
Page 13: One to rule them all

Testing Activities

Unit Testing

Acceptance Testing

Web Testing

Performance Testing

Test Definition

Page 14: One to rule them all

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
Page 16: One to rule them all

EXECUTE THE TESTS

Page 17: One to rule them all

Coverage

Page 18: One to rule them all

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

Basic usage

Page 20: One to rule them all

Usage

• Query Parameters defined as Python Dict:

• Custom headers defined as Python Dict

Page 21: One to rule them all

Usage

Basic authentication

Content body defined as Python Dict

Page 22: One to rule them all

Usage

• Upload a file:

• Cookies

• Cookies

Page 23: One to rule them all

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

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

Basic Example

Page 26: One to rule them all

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
Page 28: One to rule them all
Page 29: One to rule them all

Web Testing

• What happen with selenium IDE?

Page 30: One to rule them all

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

Config File

Page 32: One to rule them all

Script File

Page 33: One to rule them all

Example script File

Page 34: One to rule them all

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

Graphs

Page 36: One to rule them all

Graphs

Page 37: One to rule them all

Graphs

Page 38: One to rule them all

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

Jira

Page 40: One to rule them all

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

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

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

Coding example

Page 44: One to rule them all

Test Runner and report

Page 45: One to rule them all

Bonus Track

• Mocks!

– For developers

• Mockito

• Unittest.mock

– Mocking API

• Bottle

• Base HTTP

Page 46: One to rule them all

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

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

Result

Page 49: One to rule them all

Questions?