How to test API pagination?
There are multiple articles on the Intenet about how to code API pagination correctly. Does this mean that this is a good place where we should write some test cases and test some developer’s solutions? Well, there are multiple places where bugs can sit in the software. But before you start using API solutions why not check them in detail?
One of the most common mistakes is to provide not working parameters as offset or max. How to search for that kind of errors? When you want to fetch 100 results it gives only 99 of them. As a tester, you just should make a simple check and count each result entity. Check at the end did those match your max parameter. If not then you have the first kind of error found. Another simple check that you should perform is to check if those max parameter is really working for some big numbers. How big numbers use this depends on API and system but few simple checks and counting those entities will do the work.
The 2nd kind of error is visible when you set the offset parameter. Sometimes the offset is starting from the previous record which is a bug. Sometimes offset is not returning correct parameters by mixing different records on different pages. Make sure to check if displayed entities by your API are unique across some queries with the offset parameter.