[Test Scenario] Follow this to Test Pagination of Back-end like a Pro 🏆

Sajitha Pathirana
3 min readAug 10

Let’s assume the back-end is implemented with REST.

Test Pagination of BE like a PRO

RequestGET /product/search?page=1&size=10

Response

{
"metadata": {
"page": 1,
"perPage": 10,
"pageCount": 2,
"totalCount": 14
},
"results": [
{
"product": "Pen",
"quantity": "10",
"unitprice": "2""currency": "USD",
"modifiedDate": "2022–06–21T11:45:22.921238"
} ,

]
}

If you observe the response payload carefully, metadata section controls the pagination in the back end. Similar to the front-end user interface in the below article, you can change the page, size or number of records per page from the request passed as query params.

Let’s derive the possible test scenarios.

1. Check the functionality with the default values of page and size

Make the request with size 10 and page is 1

Expected
pageCount should be 1
totalCount should remain the same
perPage should be 10
All the 10 records should load

Expected Response

{
"metadata": {
"page": 1,
"perPage": 10,
"pageCount": 2,
"totalCount": 14
},
"results": [
{
"product": "Pen",
"quantity": "10",
"unitprice": "2""currency": "USD",
"modifiedDate": "2022–06–21T11:45:22.921238"
} ,
…10 …
]
}j

2. Check the functionality of the size

Change the size to 15 and page is 1

Expected
pageCount should be 1
totalCount should remain the same
perPage should be 15
All the 14 records should load

Expected Response

{
"metadata": {
"page": 1…
Sajitha Pathirana

A Test automation enthusiast, passionate to help the teams to enhance their testing journey with his decade of experience in the field.