自己写的话题详情接口测试,感觉比较傻,寻求更好的学习资料

官网测试用例的例子
Tiny Validator (for v4 JSON Schema)

自己参考了上面这两个,对话题详情接口做了一下sandbox测试。
先对collection写公共的pre-scritpt,设置一个环境变量备用。

pm.environment.set("schema_assertTrue", '{"items": {"type": "boolean"}}');

test-script如下:

pm.test("话题详情json结构", function () {
    pm.expect(pm.response.text()).to.include("id");
    pm.expect(pm.response.text()).to.include("title");
    pm.expect(pm.response.text()).to.include("body");
    pm.expect(pm.response.text()).to.include("user_id");
    pm.expect(pm.response.text()).to.include("category_id");
    pm.expect(pm.response.text()).to.include("reply_count");
    pm.expect(pm.response.text()).to.include("view_count");
    pm.expect(pm.response.text()).to.include("last_reply_user_id");
    pm.expect(pm.response.text()).to.include("excerpt");
    pm.expect(pm.response.text()).to.include("slug");
    pm.expect(pm.response.text()).to.include("created_at");
    pm.expect(pm.response.text()).to.include("updated_at");

    if(pm.expect(pm.response.text()).to.include("category")){
        if(pm.response.json().category instanceof Object){
            var data1 = [
                pm.response.json().category.hasOwnProperty('id'),
                pm.response.json().category.hasOwnProperty('description'),
                pm.response.json().category.hasOwnProperty('name'),
            ]
            pm.expect(tv4.validate(data1, pm.environment.get('schema_assertTrue'))).to.be.true;
        }
    }
});

pm.test("响应状态码", function () { 
    pm.response.to.have.status(200);
});

效果截图:
file
file

感觉这样写的比较傻,最终API黑盒测试就只能检查json格式的结构和返回的状态?

请问老师,不知道有没有更好的办法?
或者Tiny Validator (for v4 JSON Schema)这个有没有什么例子(上面那个github上的链接的例子已经找不到了)?
这里倒是找到一个文档,但是看着费劲。还不确定是不是它。。。

谢谢。

日拱一卒
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!