API 功能
检索全国或单个地区即将关闭的项目。
API - 检索即将关闭的列表脚本开发步骤
API规范->业务展示->API测试脚本调试->API测试脚本增强->API测试脚本反向案例扩展->API测试脚本发布
API规范
- 
关键请求字段
 
 
更多参考:检索即将关闭的列表
- 
关键响应字段 - 类别树。TotalCount Integer 集合中的结果总数。可以大于返回结果的数量。 TotalCountTruncated Boolean 如果结果总数超过允许的最大值并被截断,则为真。 Page Integer 当前结果页的索引(从 1 开始)。 PageSize Integer 当前页面中的结果数。 List Collection of or null 当前页面中的结果列表。 ListingId 长整数 … … … 更多参考:检索即将关闭的列表 
- 
示例请求
GET https://api.tmsandbox.co.nz/v1/Listings/closure.JSON?rows=1000
- 
示例响应
{
    "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
        },
        ...
    ]
}
业务介绍
- 
前端页面 - 转到即将关闭的列表页面
登录 > View all Closing soon in all regions
 
- 
前端页面 - 即将关闭列表页面
 
- 
业务范围选择
链式组合交易
检索您的监视列表 ->从您的监视列表中删除列表 ->检索即将关闭的列表(我在这里) ->将列表添加到您的监视列表
在即将关闭的列表的第一页获取所有项目。
- 
业务验证点
验证查询结果中是否存在关闭即将关闭列表的第一页上的项目。
API测试脚本调试
- 
在 Postman 的 Authorization 标签中选择 OAuth 1.0 对请求进行授权。
OAuth 1.0 是针对发送前需要授权的交易。模板如下:
 
- 
组合请求 -检索即将关闭的列表
根据 API 规范,参数 - rows=1000表示要返回的最大结果数。
所以请求应该是 GET https://api.tmsandbox.co.nz/v1/Listings/closure.JSON?rows=1000
 
- 
API连通性
连通性测试通过并获得响应示例。
{
    "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检查点
检查响应中是否有即将关闭的项目。
然后我们根据示例功能得到下面的检查代码片段。
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");
    }
    
});
运行脚本以从控制台日志验证检查点是否正常工作。
 
 
API 测试脚本增强
增强脚本,如添加事务功能、异常验证、参数化等。
运行最终脚本并从前端页面或控制台日志进行验证。
API 测试脚本否定案例扩展
使用我们在手动测试案例中所做的“等效类划分”和“边界值分析”。
这些API测试脚本都是做反方向的业务,作为上述API正案例的延伸。
API测试脚本发布
当我们完成 API 正面和反面案例时,将脚本从调试文件夹移动到公共文件夹。
然后等待使用 CICD 工具与其他脚本结合发布到 GitHub 特定存储库。