2. Agenda
• WTF is an API?
• Why would you automate an API?
• Serious cognitive barriers
• What tests worth automating
• Setup and environment
• The framework
4. Bullshit warning!
I commit to:
• Not giving you a “how to”
• No 30 mins introduction
• No “live coding misery”
• No “best practices”
5. Who am I: Viktor Slavchev
• Software tester, speaker and
teacher in testing
• Blog: mrslavchev.com
• @thetestingtroll
• Insert random brag about my
achievements
• This slide is bullshit
• Nobody reads this far
15. Few (un)obvious reasons to
automate via API
• Clear definitive response
• Close to client
• Good failure visibility
• Easy to test with code
Source: Models of automation
17. Setup, tech stack, context
• Restful API written in Php
• ReactJS front-end
• Docker compose – test env
• Codeception – testing tool
• Custom tools to produce data
19. Cognitive barriers
Few things to have in mind:
• The doc is not the product
• Your coding skills will hold you
back
• The need to explore
• Tests that pass vs. tests that test
20. What tests are worth automating?
… but first – what bugs do we care
testing for?
• Service returning wrong response code
• Throwing 500
• Returning wrong data
• No data at all
• Interaction problems
21. What test are worth automating?
• Status code checks
• Structure checks
• Scenario checks
25. Structure checks – pros and cons
Pros:
•Verify data
• Can be very specific
• Can use regex
(Codecept)
Cons:
•Useful for content only
•Suck with variable data
•Suck with deep
nesting/long responses
27. Scenario checks – pros and cons
Pros:
• Closest to client
interaction
• Expose integration
problems
• Can be used as shallow
regression suite
Cons:
•Slow to run/develop
•Require better
abstraction
•Hard to say when it is
too much
34. Let your framework mature
• Your framework will suck at first
• It will improve incrementally
• It can’t be done in the beginning
35. Splitting logic of the test and logic of
the app
• Move common actions to base
classes
• Move common prerequisites to
setup methods
• Build inheritance trees
• Reuse rather than repeat
36. Useful resources
• Hindsight lessons about API testing
• Automating and Testing a REST API – book by
Alan Richardson
• This article by Smart Bear
• Service virtualization by Bas Dijkstra free e-book
• Your brain!!!