Trade Me-6-Retrieve closing soon listings API testing | Postman API automation testing

API Function

Retrieves the items closing soon for the whole country or for a single region.

API - Retrieve closing soon listings script development steps

API Specification -> Business Presentation -> API Testing Script Debugging -> API Testing Script Enhancement -> API Testing Script Negative Cases Extension -> API Testing Script Publishment

API Specification

  • Key request fields

​ More refer to: Retrieve closing soon listings

  • Key response fields - A category tree.

    TotalCount Integer The total number of results in the collection. Can be larger than the number of returned results.
    TotalCountTruncated Boolean True if the total count of results exceeded the allowed maximum and was truncated.
    Page Integer The index of the current page of results (starts at 1).
    PageSize Integer The number of results in the current page.
    List Collection of or null A list of the results in the current page.
    ListingId Long Integer

    More refer to: Retrieve closing soon listings

  • Example request

GET https://api.tmsandbox.co.nz/v1/Listings/closing.JSON?rows=1000

  • Example response

{
    "TotalCount": 250,
    "Page": 1,
    "PageSize": 250,
    "List": [
        {
            "ListingId": 2149292446,
            "Title": "fox drawing",
            "Category": "0339-5487-",
            "StartPrice": 0,
            "BuyNowPrice": 1.0000,
            "StartDate": "/Date(1626323575513)/",
            "EndDate": "/Date(1626928375513)/",
            "ListingLength": null,
            "AsAt": "/Date(1626926636817)/",
            "CategoryPath": "/Art/Digital-art",
            "Region": "Canterbury",
            "Suburb": "Christchurch City",
            "HasBuyNow": true,
            "NoteDate": "/Date(0)/",
            "ReserveState": 3,
            "IsBuyNowOnly": true,
            "PriceDisplay": "$1.00 per item",
            "PromotionId": 1,
            "AdditionalData": {
                "BulletPoints": [],
                "Tags": []
            },
            "MemberId": 4007247
        },
        ...
    ]
}

Business Presentation

  • Front-end page - Go to closing soon listings page

Login > View all Closing soon in all regions

  • Front-end page - closing soon listings page

  • Business scope selection

Chained combination transactions

Retrieve your watchlist -> Remove a listing from your watchlist -> Retrieve closing soon listings(I’m here) -> Add a listing to your watchlist

Get all the items at 1st page of the closing soon listings.

  • Business verification points

Verify items on the 1st page of closing soon listings exist in the query result.

API Testing Script Debugging

  • Choose the OAuth 1.0 in the Authorization label of Postman to authorize the request.

The OAuth 1.0 is for the transaction that needs to be authorized before sending. Template likes the below:

Base on the API specification, parameter - rows=1000 means the maximum number of results to return.

So the request should be GET https://api.tmsandbox.co.nz/v1/Listings/closing.JSON?rows=1000

  • API connectivity

The connectivity test passes and gets a response example.

{
    "TotalCount": 250,
    "Page": 1,
    "PageSize": 250,
    "List": [
        {
            "ListingId": 2149294548,
            "Title": "Princess Pink of Ballerina",
            "Category": "0347-1417-6174-",
            "StartPrice": 9.0000,
            "BuyNowPrice": 16.7500,
            "StartDate": "/Date(1626759267867)/",
            "EndDate": "/Date(1627364067867)/",
            "ListingLength": null,
            "HasGallery": true,
            "AsAt": "/Date(1627362314009)/",
            "CategoryPath": "/Toys-models/Pretend-playing/Other",
            "PictureHref": "https://images.tmsandbox.co.nz/photoserver/thumb/4549071.jpg",
            "IsNew": true,
            "Region": "Wellington",
            "Suburb": "Wellington City",
            "HasReserve": true,
            "HasBuyNow": true,
            "NoteDate": "/Date(0)/",
            "ReserveState": 2,
            "PriceDisplay": "$9.00",
            "PromotionId": 2,
            "AdditionalData": {
                "BulletPoints": [],
                "Tags": []
            },
            "MemberId": 4003082
        },
        ...
    ]
}        
  • API checkpoint

Check whether it has closing soon items in the response.

Then we get the checking code snippet below base on the example feature.

pm.test("Checking if there are any items in the Closing Soon Listings", function () {

    console.log("Post-Transaction: CheckingtheCountsofClosingSoonListings Start");

    var jsonData = pm.response.json();

    var TotalCount = jsonData.TotalCount;  

    if (TotalCount >= 0){

        console.log("Found " + TotalCount +" items in the Closing Soon Listings");

        console.log("Post-Transaction: CheckingtheCountsofClosingSoonListings Pass");

    }

    else{

        console.log("Post-Transaction: CheckingtheCountsofClosingSoonListings Failed");

    }
    
});

Run script to verify the checkpoint works from console log.

API Testing Script Enhancement

Enhance the script, such as to add the transactional function, exceptional verification, parameterization, etc.

Run the final script and to verify from front-end page or console log.

API Testing Script Negative Cases Extension

Using the ‘Equivalent Class Partitioning’ and ‘Boundary Value Analysis’ as we did in manual testing cases.

These API test scripts are doing the negative direction of the business, to be an extension to the above API positive case.

API Testing Script Publishment

Move script from debug folder to public folder when we finished API positive and negative cases.

Then wait to be published to the GitHub specific repo combining with other scripts using the CICD tool.

Copyright

This work is licensed under CC BY-NC-ND 4.0 .