How to improve our acceptance tests - Pyccuracy VS Splinter

1,480 views

Published on

Some thoughts about acceptance tests and the tools Pyccuracy and Splinter

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

How to improve our acceptance tests - Pyccuracy VS Splinter

  1. 1. Fernando SandesHow toimprove ouracceptance tests !
  2. 2. What is better?Pyccuracy vs
  3. 3. It`s not (only) aboutthe technology
  4. 4. It`s anideologica difference
  5. 5. @gabrielfalcao Lettuce`s creatorThe problem is that differently ofcucumber and lettuce, pyccuracy isaimed to web testing, with pre-defined"step definitions" (pyccuracy uses adifferent nomenclature), and when I wasusing it I found extremely hard tomaintain the tests as the test suitegrows, its a hell! lettuce
  6. 6. @gabrielfalcao Lettuce`s creator“So I wrote lettuce to make it super flexibleso that I could write my own definitions in a supereasy way, and never couple my tests to roboticstep definitions.” lettuce
  7. 7. Pyccuracy ROBOTIC STEP DEFINITIONS
  8. 8. ROBOTIC STEP DEFINITIONSGiven 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!" 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 Im logged in as a normal user
  9. 9. ROBOTIC STEP DEFINITIONSGiven 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” 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 Im logged in as a normal user
  10. 10. DONT`T BE THE BOILING FROG !The presence of step definitions leads people down a verybad path.While it gives people a head start in writing scenarios italso tricks people into writing scenarios are extremelyverbose and fragile.People dont always realize this, so they continue crankingout lots of crap scenarios based on pre-steps. This is likethe boiling frog story
  11. 11. 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.
  12. 12. PyccuracyIS BUROCRATIC !
  13. 13. a little more…
  14. 14. Imperative VS Declarative Scenarios in User Stories
  15. 15. The imperative style uses highly reusableImperative granular steps which outlines user interface. much of the This binds the scenario to that interface.Scenario: Successful loginGiven a user "Aslak" with password "xyz"And I am on the login pageAnd 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“
  16. 16. The imperative style uses highly reusableImperative granular steps which outlines user interface. much of the This binds the scenario to that interface.Scenario: Successful login Scenario: User is greeted upon loginGiven a user "Aslak" with password "xyz" Given the user "Aslak" has an accountAnd I am on the login page When he logs inAnd I fill in "User name" with "Aslak" Then he should see "Welcome, Aslak"And I fill in "Password" with "xyz"When I press "Log in"Then I should see "Welcome, Aslak“ Declarative
  17. 17. The imperative style uses highly reusableImperative granular steps which outlines user interface. much of the This binds the scenario to that interface.Scenario: Successful login Scenario: User is greeted upon loginGiven a user "Aslak" with password "xyz" Given the user "Aslak" has an accountAnd I am on the login page When he logs inAnd I fill in "User name" with "Aslak" Then he should see "Welcome, Aslak"And I fill in "Password" with "xyz"When I press "Log in"Then I should see "Welcome, Aslak“ Declarative
  18. 18. Imperative DeclarativeWhen we’re describing other parts of the system thatrequire login, the login details like user name, passwordand how to log in are only distracting. That is whywe make it a one-liner.
  19. 19. Imperative Declarative
  20. 20. Imperative Declarative
  21. 21. 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.
  22. 22. COMING BACK… And about technology
  23. 23. SPLINTERSplinter was not created to be another acceptancetool, but an abstract layer over othertools, its goal is provide a unique API that makeacceptance testing easier and funnier :)
  24. 24. SPLINTERA LOT OF OPTIONS !
  25. 25. HEADLESS OR NOT HEADLESS ?
  26. 26. HEADLESSFASTCHEAPHARD TO DEBUGIT`S NOT A BROWSER!
  27. 27. NOT HEADLESSSLOWEASY TO DEBUGUSE THE BROWSER
  28. 28. HEADLESSNOT HEADLESS SPLINTER
  29. 29. SERVERLOCAL
  30. 30. SERVER HEADLESSLOCAL
  31. 31. NOT HEADLESS SERVER HEADLESS LOCAL
  32. 32. SPLINTER and more…http status codemulti webdriverscss ,xpath, tag, name selectorssupport to iframe and alertexecute javascriptworks with ajax and async javascript
  33. 33. SPLINTERBrowser• visit(‘url’)• reload()• quit()• html• url• title
  34. 34. SPLINTERSearching elements• find_by_css(‘.classe’)• find_by_id(‘meuid’)• find_by_xpath(‘//body’)• find_by_tag(‘a’)• find_by_name(‘search’)
  35. 35. SPLINTER Forms• fill(‘name’, ‘value’)• attach_file(‘name’, ‘/path/to/file.txt’)• check(‘name’) #checkbox• choose(‘name’, ‘value’) #radio button• select(‘name’, ‘option’)
  36. 36. MORETESTS
  37. 37. SIKULI http://sikuli.org/index.shtml
  38. 38. NEEDLE http://needle.readthedocs.org #AUTOMATED TESTS FOR CSS 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)

×