How to Automate API Testing
-
Upload
bruno-pedro -
Category
Engineering
-
view
1.752 -
download
0
Transcript of How to Automate API Testing
![Page 1: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/1.jpg)
Bruno PedroJanuary 2016
How to Automate API Testing
![Page 2: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/2.jpg)
Summary• types of API testing
• functional testing
• API exploration
• writing and running tests locally
• automating test execution
![Page 3: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/3.jpg)
3 types of API Testing
• unit testing
• functional testing
• load testing
increased complexity
![Page 4: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/4.jpg)
Unit Testing• part of the development process
• usually written by developers
• tests how local code integrates with the API
• focused on request and response handling
• automated by a CI process
![Page 5: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/5.jpg)
Unit Testing: mocking• actual API response is saved locally
• test uses local copy of API response
• several tools for different programming languages
• VCR (Ruby)
• nock (Node.js)
![Page 6: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/6.jpg)
Functional Testing• part of the QA process
• a kind of black-box testing
• focused on response generation
• often executed periodically
• tests how the API behaves under a controlled input
![Page 7: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/7.jpg)
Functional Testing: identification
• which API calls should be tested
• how are those calls used by the application
• what should be tested
• who should be notified if tests fail
![Page 8: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/8.jpg)
Functional Testing: input
• usually fake data
• information that resembles real usage
• often obtained by studying user input
• updated often
![Page 9: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/9.jpg)
Functional Testing: output• tests should be similar to unit tests
• but performed on real API calls
• additional output
• response time
• specific API responses during testing
![Page 10: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/10.jpg)
Functional Testing: execution
• manual crafting
• manually triggered
• potentially executed periodically
• result flags CI process
![Page 11: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/11.jpg)
API Exploration
• starts in the product development phase
• part of the product definition
• confirmed in the development process
• validated by QA
![Page 12: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/12.jpg)
API Exploration: questions
• why are you using the API
• what API calls are used
• how does the product integrate with the API
• what happens if the API fails or is unresponsive
![Page 13: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/13.jpg)
API Exploration: hands-on
• getting a list of all the relevant API calls
• obtaining authorization credentials if needed
• preparing fake input data
• exploring the API calls manually
![Page 15: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/15.jpg)
API Exploration: hands-on
![Page 16: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/16.jpg)
API Exploration: hands-on
collections are a way to group API calls
![Page 17: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/17.jpg)
Local Tests
• one-off testing
• batch testing
• easy to validate
• a way to discover unanticipated API responses
![Page 18: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/18.jpg)
Local Tests: hands-on
written in javascript and executed locally
![Page 19: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/19.jpg)
Local Tests: hands-on
![Page 20: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/20.jpg)
Local Tests: hands-on
![Page 21: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/21.jpg)
Automated Tests
• repeatable process
• periodic execution
• possibly flagging CI
• dedicated or SaaS solutions
![Page 23: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/23.jpg)
Automated Tests: hands-on
test scheduling using Runscope
![Page 24: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/24.jpg)
Automated Tests: hands-on
test metrics provided by Runscope
![Page 25: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/25.jpg)
Wrap up• unit and functional API testing
• identification, input, output and execution
• API exploration and introduction to Postman
• local testing with Postman
• automating tests with runscope
![Page 27: How to Automate API Testing](https://reader033.fdocuments.net/reader033/viewer/2022051503/58714d9e1a28ab55588b723f/html5/thumbnails/27.jpg)
+
Sean O’ConnorLead Engineer
It's great to see a tool like API Changelog come along. (…) as an API provider, it's always
a challenge to communicate to users when changes happen.
Get in touch!
Bruno Pedro
Thank you