检查Postman测试中作为JSON一部分返回的URL的HTTP状态

时间:2018-10-14 17:31:54

标签: postman postman-collection-runner

我的JSON模式(API响应)在邮递员中已成功完成TESTS,但还想检查API返回的URL是否可访问(HTTP状态200)。我该如何在测试中进行子查询?

我拥有的JSON类似于:

{
    "success": 1,
    "filelist": [
        {
            "group_name": "xxxx",
            "group_position": 2,
            "track_name": "xxxx",
            "track_position": 1,
            "is_product_id": 105,
            "url": "https://xxx.mp3",
            "type": 0
        },
        {
            "group_name": "xxx",
            "group_position": 2,
            "track_name": "xxx",
            "track_position": 2,
            "is_product_id": 105,
            "url": "https://xxx.mp3",
            "type": 0
        },
    ]
}

我正在检查数组中每个项目的架构,例如:

var response = JSON.parse(responseBody);
for (var file in response.filelist) {
    var trackItem = response.filelist[file];
    var testName = "Schema for " + trackItem.track_name;
    tests[testName] = tv4.validate(trackItem, fileSchema);
}

,并希望检查项目包含的每个URL是否在同一周期内可访问(HTTP STATUS 200)。有可能吗?

0 个答案:

没有答案