I am writing an API client in php that sends request to an API server to get the details of a person based on his ID on the API server. The API server has a token based authentication and when queried with the correct ID and the token, the details of that person are returned as a JSON response. I am comfortable with the implementation of the class. However, when it comes to unit testing, I have not much idea about what all should be the best test cases that I should write. Unfortunately, I couldn't find any resources on the same. I have written a few test cases that validates the request parameters and the end point to query. Can anyone shed some more light on unit testing API clients?
Related Questions in PHP
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
Related Questions in API
- SuiteCRM how to retrieve all account related contacts
- how do i submit a pastebin or pastee from an android app and get the url back
- BigCommerce PHP API delete Category which contains products
- Interact with chrome bookmarks outside of extensions
- purchase individual items and subscriptions in the same PayPal REST API transaction
- youtube api v3 insert comments
- Youtube api v3 duration
- Responding to an Office 365 event invite via REST
- Convert youtube video to mp3 using Quick MP3 API
- How to real-time monitor the emails?
Related Questions in UNIT-TESTING
- How to write tests for classes with inheritance
- PHPunit call magic methods
- Convert IEnumerable to IObservable with variable Period
- How to a run specific code before & after each unit test in Python
- Unit testing a class A that derives from an abstract class B
- Is there another way to unit test business logic in mvc
- Some of my tests show prepended with junit.framework
- Selenium Driver Service not found exception
- Can not convert from Class<PowerMockRunner> to Class<? extends Runner>
- AngularJS Unit Testing - multiple mocks and providers
Related Questions in PHPUNIT
- PHPunit call magic methods
- PHPUnit testing socket
- Yii phpunit error SeleniumTestCase.php fail to open stream
- cakephp test filter do not execute
- How to use phpunit with DBUnit on IBM DB2?
- Laravel 5.1 testing with PHPUnit and PHPSpec
- What's a good way to test a user factory that depends on an external API call
- phpunit debugging only going into phpunit.phar file
- Calling a method of a mock object
- Unable to find wrapper when testing Guzzle call with PHPUnit
Related Questions in APICLIENT
- python people api quit working
- HMAC value calculated from Java is not matching with Ruby code
- How to timeout, or limit the waiting time for a response from an external API
- Crittercism API Crash Trends Data For Custom Time Period
- Error when trying to send data from APIClient to a function using multiprocessing
- How to nest endpoints in a API client with interfaces while keeping readability
- Abstract classes on client generated code from swagger spec API net core
- Unit testing a PHP API client
- Query parameters in PUT call of APIClient
- API call successfully from external client but not from c#
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I am not a test expert but I do test when creation libs and components, so these are my advices.
Usually when I do similar tasks as you described, I create a library as a facade of the remote API, that ( possibly ) simplifies them.
So I have two distinguished types of tests, "unit test" and "integration test": the former are test for library components to check that they give correct results against different data model passed in input, the latter to check if library call ( eg. "getPersonDetails" that internally makes one or more remote API requests ) gives the correct result.
In your case you may create an "integration test" for your "getPersonDetails" method to check if the remote API ( possibly TEST environment ) gives answer and if your method's response is what you expect. You can also try to pass wrong input data anche check to raise the correct exception etc.
Any internal components that are used within "getPersonDetails" can be tested in "unit test".