API testing doesn't involve a GUI but the testing does come down to the same concepts of inputs and outputs. You provide a specific input and you get the expected output. Just like with any type of testing, the methodology is the same. You would verify the Happy Path, and try and break the API (passing invalid parameters, too many parameters, etc. and verify errors are thrown gracefully, that databases are not updated with empty rows, or duplicate data... and son on.)
What this API was doing was taking the userid as a parameter and passing it into a SQL insert to our test db.
Testing it was amounting to:
But... there are easier ways. You could find a open/public API and work with it. Some examples of API's you could start with would be:
http://daccg.com/ajax_ccgsearch.php?cardname=jace%20beleren
You can simply set up a form to pass in a parmeter here (URL encoded of course) and get back some JSON with the result!
The above list is of course online API's, many of them restful service with API's you can hit with a URI endpoint. But it is easy to get started right now!
So what is an API?
An API is a interface you can use in development, it stands for Application Programming Interface. Think of it as a building block of code. Rather then writing that code each time, you have a block of code that can take parameters and use those parameters to do something. You could pass in parameters to create a user in a db, or perform a query and return data as JSON, or handle authentication (such as Facebook login api's.) API's can be public or private.Verifying An API
Some examples to verify in API testing could be:- What does the API return? If an API is designed to return a result (like data), then you would want to know that a) there is something returned and b) it's what's expected and c) it fits the boundaries of what's expected d) errors are handled correctly
- Event Listener Testing: If the API is making an event, you would have to have access to an event listener or event log and verify that the event is a) captured correctly b) it's in the expected format and c) has the correct payload d) errors are handled correctly
- Modifying Databases: If the API is making a DB insert or update, you would want to verify that a) the db update/insert/delete occurs b) the data that is changed is correct c) errors are handled correctly.
What this API was doing was taking the userid as a parameter and passing it into a SQL insert to our test db.
Testing it was amounting to:
- The Happy Path: Does the data insert/update for a userid reach the db. New users would be inserted to the db, existing users would be updated.
- Validate the data inserted: are all columns expected to be updated, updated? Is the user flagged as a subscriber?
- Error Cases: What happens if an empty string is passed in? it should error gracefully, does it? What happens if the user is already a subscriber. That would mean the insert would fail for new users. Updates would pass.
- Events: In this case we didn't want to trigger any events. This should bypass the events, so just double check that no events are recorded in the event service logs.
How To Get Into API Testing
There's a lot of ways a person can pick up API testing on their own. If you can write code in Rails/Ruby, Groovy, JAVA, etc, you could build your API and then test it!But... there are easier ways. You could find a open/public API and work with it. Some examples of API's you could start with would be:
- Rotten Tomatoes - http://developer.rottentomatoes.com/ This is a great API to work with. It's very easy to pass parameters to and get back JSON data.
- Facebook - https://developers.facebook.com/docs/reference/apis/
- Google Maps - https://developers.google.com/maps/
http://daccg.com/ajax_ccgsearch.php?cardname=jace%20beleren
You can simply set up a form to pass in a parmeter here (URL encoded of course) and get back some JSON with the result!
The above list is of course online API's, many of them restful service with API's you can hit with a URI endpoint. But it is easy to get started right now!
No comments:
Post a Comment