how to improve our acceptance tests - pyccuracy vs splinter

39
How to improve our acceptance tests ! Fernando Sandes

Upload: fernando-sandes

Post on 24-Apr-2015

1.490 views

Category:

Technology


0 download

DESCRIPTION

Some thoughts about acceptance tests and the tools Pyccuracy and Splinter

TRANSCRIPT

Page 1: How to improve our acceptance tests - Pyccuracy VS Splinter

How to improve our acceptance tests !

Fernando Sandes

Page 2: How to improve our acceptance tests - Pyccuracy VS Splinter

Pyccuracy vs

What is better?

Page 3: How to improve our acceptance tests - Pyccuracy VS Splinter
Page 4: How to improve our acceptance tests - Pyccuracy VS Splinter

It`s not (only)

the technology about

Page 5: How to improve our acceptance tests - Pyccuracy VS Splinter

It`s an ideological

difference

Page 6: How to improve our acceptance tests - Pyccuracy VS Splinter

The problem is that differently of cucumber and lettuce, pyccuracy is aimed to web testing, with pre-defined "step definitions" (pyccuracy uses a different nomenclature), and when I was using it I found extremely hard to maintain the tests as the test suite grows, it's a hell!

lettuce

@gabrielfalcao Lettuce`s creator

Page 7: How to improve our acceptance tests - Pyccuracy VS Splinter

“So I wrote lettuce to make it super flexible so that I could write my own definitions in a super

easy way, and never couple my tests to robotic step definitions.”

lettuce

@gabrielfalcao Lettuce`s creator

Page 8: How to improve our acceptance tests - Pyccuracy VS Splinter

Pyccuracy

ROBOTIC STEP

DEFINITIONS

Page 9: How to improve our acceptance tests - Pyccuracy VS Splinter

ROBOTIC STEP DEFINITIONS

Given I am at the login page

And I fill in the login information with "test" and password "1234"

When I click on the login button

Then I see I'm logged in as a normal user

Given I fill the field "#username" with "test"

And I fill the field "#password" with "1234"

When I click on the button 'input[type="submit"]'

Then I see the page contains the text "Hello Test User!"

Page 10: How to improve our acceptance tests - Pyccuracy VS Splinter

ROBOTIC STEP DEFINITIONS

Given I am at the login page

And I fill in the login information with "test" and password "1234"

When I click on the login button

Then I see I'm logged in as a normal user

Given I fill the field "#username" with "test"

And I fill the field "#password" with "1234"

When I click on the button 'input[type="submit"]'

Then I see the page contains the text "Hello Test User!"

“You can see how your business it better defined here”

Page 11: How to improve our acceptance tests - Pyccuracy VS Splinter

DONT`T BE THE

BOILING FROG

The presence of step definitions leads people down a very

bad path. While it gives people a head start in writing scenarios it also tricks people into writing scenarios are extremely

verbose and fragile. People don't always realize this, so they continue cranking out lots of crap scenarios based on pre-steps. This is like the boiling frog story

!

Page 12: How to improve our acceptance tests - Pyccuracy VS Splinter

IT`S ABOUT THE DOMAIN !

The “domain” is defined by the value the stakeholders and users hope to achieve with the software.

This can be booking a ticket or sharing pictures with friends or an infinite number of activities. Clicking links and buttons or filling in text fields has nothing (directly) to do with the domain.

Page 13: How to improve our acceptance tests - Pyccuracy VS Splinter

IS BUROCRATIC !

Pyccuracy

Page 14: How to improve our acceptance tests - Pyccuracy VS Splinter

a little more…

Page 15: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative

VS Declarative

Scenarios in User Stories

Page 16: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative The imperative style uses highly reusable granular steps which outlines much of the

user interface.

This binds the scenario to that interface.

Scenario: Successful login Given a user "Aslak" with password "xyz" And I am on the login page And I fill in "User name" with "Aslak" And I fill in "Password" with "xyz" When I press "Log in" Then I should see "Welcome, Aslak“

Page 17: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative The imperative style uses highly reusable granular steps which outlines much of the

user interface.

This binds the scenario to that interface.

Scenario: Successful login Given a user "Aslak" with password "xyz" And I am on the login page And I fill in "User name" with "Aslak" And I fill in "Password" with "xyz" When I press "Log in" Then I should see "Welcome, Aslak“

Scenario: User is greeted upon login Given the user "Aslak" has an account When he logs in Then he should see "Welcome, Aslak"

Declarative

Page 18: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative The imperative style uses highly reusable granular steps which outlines much of the

user interface.

This binds the scenario to that interface.

Scenario: Successful login Given a user "Aslak" with password "xyz" And I am on the login page And I fill in "User name" with "Aslak" And I fill in "Password" with "xyz" When I press "Log in" Then I should see "Welcome, Aslak“

Scenario: User is greeted upon login Given the user "Aslak" has an account When he logs in Then he should see "Welcome, Aslak"

Declarative

Page 19: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative

When we’re describing other parts of the system that require login, the login details like user name, password

and how to log in are only distracting. That is why

we make it a one-liner.

Declarative

Page 20: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative Declarative

Page 21: How to improve our acceptance tests - Pyccuracy VS Splinter

Imperative Declarative

Page 22: How to improve our acceptance tests - Pyccuracy VS Splinter

COMMUNICATION IS THE GOAL!

To use a BDD tool "right", one has to understand

that the main goal is primarily about communication and secondarily about testing.

Page 23: How to improve our acceptance tests - Pyccuracy VS Splinter

COMING BACK…

And

technology about

Page 24: How to improve our acceptance tests - Pyccuracy VS Splinter

SPLINTER

Splinter was not created to be another acceptance

tool, but an abstract layer over other tools, its goal is provide a unique API that make

acceptance testing easier and funnier :)

Page 25: How to improve our acceptance tests - Pyccuracy VS Splinter

SPLINTER

A LOT OF OPTIONS !

Page 26: How to improve our acceptance tests - Pyccuracy VS Splinter

OR NOT HEADLESS ? HEADLESS

Page 27: How to improve our acceptance tests - Pyccuracy VS Splinter

HEADLESS

FAST CHEAP HARD TO DEBUG IT`S NOT A BROWSER!

Page 28: How to improve our acceptance tests - Pyccuracy VS Splinter

NOT HEADLESS

SLOW EASY TO DEBUG USE THE BROWSER

Page 29: How to improve our acceptance tests - Pyccuracy VS Splinter

NOT HEADLESS

HEADLESS

SPLINTER

Page 30: How to improve our acceptance tests - Pyccuracy VS Splinter

LOCAL

SERVER

Page 31: How to improve our acceptance tests - Pyccuracy VS Splinter

LOCAL

SERVER

HEADLESS

Page 32: How to improve our acceptance tests - Pyccuracy VS Splinter

LOCAL

SERVER

HEADLESS

NOT HEADLESS

Page 33: How to improve our acceptance tests - Pyccuracy VS Splinter

SPLINTER and more…

http status code

multi webdrivers

css ,xpath, tag, name selectors

support to iframe and alert

execute javascript

work's with ajax and async javascript

Page 34: How to improve our acceptance tests - Pyccuracy VS Splinter

SPLINTER Browser

• visit(‘url’)

• reload()

• quit()

• html

• url

• title

Page 35: How to improve our acceptance tests - Pyccuracy VS Splinter

SPLINTER Searching elements

• find_by_css(‘.classe’)

• find_by_id(‘meuid’)

• find_by_xpath(‘//body’)

• find_by_tag(‘a’)

• find_by_name(‘search’)

Page 36: How to improve our acceptance tests - Pyccuracy VS Splinter

SPLINTER Forms

• fill(‘name’, ‘value’)

• attach_file(‘name’, ‘/path/to/file.txt’)

• check(‘name’) #checkbox

• choose(‘name’, ‘value’) #radio button

• select(‘name’, ‘option’)

Page 37: How to improve our acceptance tests - Pyccuracy VS Splinter

MORE

TESTS

Page 38: How to improve our acceptance tests - Pyccuracy VS Splinter

SIKULI

http://sikuli.org/index.shtml

Page 39: How to improve our acceptance tests - Pyccuracy VS Splinter

NEEDLE

from needle.cases import NeedleTestCase

class GoogleTest(NeedleTestCase):

def test_footer(self):

self.driver.get('http://www.google.com')

e = self.driver.find_element_by_id('fctr')

self.assertScreenshot(e, 'google-footer')

self.assertEqual(e.get_computed_property('font-size'), '13px')

http://needle.readthedocs.org

#AUTOMATED TESTS FOR CSS