+ All Categories
Transcript
Page 1: Browser based testing

Pitfalls and tips with Pitfalls and tips with browser based browser based

testIngtestIng

Page 2: Browser based testing

My Background

several projects with functional testing

consulted at organizations to introduce functional testing and builds

heavily involved in trying to improve effectiveness and reduce maintenance

developed a framework over several projects that made use of my learnings

Page 3: Browser based testing

Common uses of functional tests

smoke/sanity tests for most valuable and risky features

black box/regression tests

post deployment checks and rollbacks

multi browser testing

Page 4: Browser based testing

what do we want from tests?

correctness (when my tests work, my application is not broken)

robustness (when my tests break, my application is broken)

Page 5: Browser based testing

what do we focus on?

what’s valuable? (it matters to us that people can do this)

what’s risky? (if this breaks, it really affects us)

Page 6: Browser based testing

so whats the so whats the problem?problem?

Page 7: Browser based testing

five problemsfive problems

Page 8: Browser based testing

1. slow tests1. slow tests

Page 9: Browser based testing

BecauseBecause

Page 10: Browser based testing

uses the uses the entire stackentire stack

Page 11: Browser based testing

low spec hardwarelow spec hardware

Page 12: Browser based testing

tons of setuptons of setupand teardownand teardown

Page 13: Browser based testing

talking to the talking to the browser is slowbrowser is slow

Page 14: Browser based testing

soso

Page 15: Browser based testing

very long feedback very long feedback looploop

Page 16: Browser based testing

can delay can delay deploymentsdeployments

Page 17: Browser based testing

2. Brittle tests2. Brittle tests

Page 18: Browser based testing

UI UI changes changes

a lota lot

Page 19: Browser based testing

tests over tests over specifyspecify

Page 20: Browser based testing

3. Random failures3. Random failures

Page 21: Browser based testing

race conditionsrace conditions

Page 22: Browser based testing

unreliable unreliable dependenciesdependencies

Page 23: Browser based testing

4. tests are hard to 4. tests are hard to debugdebug

Page 24: Browser based testing

too many too many tests breaktests break

Page 25: Browser based testing

error messageserror messagestell you nothingtell you nothing

Page 26: Browser based testing

5. test code becomes 5. test code becomes unmaintainableunmaintainable

Page 27: Browser based testing

insufficient insufficient commitment to commitment to

testingtesting

Page 28: Browser based testing

inadequate inadequate understanding understanding

of testingof testing

Page 29: Browser based testing

what happens

there is an initial stream of tests

tests break unnecessarily

tests become hard to maintain

team loses confidence and motivation

some teams even abandon testing via the UI

Page 30: Browser based testing

tips and trickstips and tricks

Page 31: Browser based testing

Treat test codelike real code

speed

maintainability

Page 32: Browser based testing

A lot of the techniques we A lot of the techniques we use with real code work use with real code work

with test codewith test code

Page 33: Browser based testing

similar levels of similar levels of commitmentcommitment

Page 34: Browser based testing

test test creation/maintenancecreation/maintenancecan be part of the dev can be part of the dev

cyclecycle

Page 35: Browser based testing

Use Ruby

maintainability

development time

Page 36: Browser based testing

use a headless browser when possible

speed

Page 37: Browser based testing

Use selenium RC (if you use selenium)

avoid brittleness

maintainability

Page 38: Browser based testing

Don’t record and replay

(if you use selenium)

avoid brittleness

maintainability

development time

Page 39: Browser based testing

Introduce an Abstraction layer

speed

maintainability

Page 40: Browser based testing

Categorize/tag tests

speed

maintainability

Page 41: Browser based testing

Use the page object pattern

maintainability

Page 42: Browser based testing

Parallelize

speed

Page 43: Browser based testing

separate data for tests

speed

avoid random failures

Page 44: Browser based testing

clump data into common location

maintainability

Page 45: Browser based testing

Push setup and teardown out of tests

speed

avoid brittleness

development time

debuggability

Page 46: Browser based testing

Only exercise parts of the application you

want to testspeed

avoid brittleness

debuggability

Page 47: Browser based testing

Build stub services

speed

avoid random failures

Page 48: Browser based testing

don’t over specify

avoid brittleness

debuggability

Page 49: Browser based testing

run on better hardware

speed

Page 50: Browser based testing

slice vertically

debuggability

Page 51: Browser based testing

Use the right locator

maintainability

avoid brittleness

speed

Page 52: Browser based testing

learn xpath/css selectors

avoid brittleness

maintainability

Page 53: Browser based testing

fail later

speed

Page 54: Browser based testing

use polls over sleep

speed

avoid random failures

Page 55: Browser based testing

use existing waits of selenium

speed

avoid random failures

avoid brittleness

avoid random

Page 56: Browser based testing

Don’t use assertions to identify transitions

avoid brittleness

debuggability

avoid brittleness

avoid random

Page 57: Browser based testing

screenshots and html dumps

debuggability

Page 58: Browser based testing

xpath/css selector tester

development time

Page 59: Browser based testing

firebug or w/e

development time

maintainability

Page 60: Browser based testing

talk to me if you’re talk to me if you’re testing tabular datatesting tabular data

Page 61: Browser based testing

I’m always available I’m always available for questionsfor questions

Page 62: Browser based testing

Questions?Questions?

Page 63: Browser based testing

thank youthank you


Top Related