Postman断言

1.

{
    "avatar_large": "//cdn.v2ex.com/navatar/8613/985e/90_large.png?m=1542789127",
    "name": "python",
    "avatar_normal": "//cdn.v2ex.com/navatar/8613/985e/90_normal.png?m=1542789127",
    "title": "Python",
    "url": "https://www.v2ex.com/go/python",
    "topics": 10441,
    "footer": "",
    "header": "这里讨论各种 Python 语言编程话题,也包括 Django,Tornado 等框架的讨论。这里是一个能够帮助你解决实际问题的地方。",
    "title_alternative": "Python",
    "avatar_mini": "//cdn.v2ex.com/navatar/8613/985e/90_mini.png?m=1542789127",
    "stars": 7256,
    "root": false,
    "id": 90,
    "parent_node_name": "programming"
}

var jsonData = JSON.parse(responseBody);

tests["check code id is 90"] =jsonData.id ===90;
tests["check code url value"] = jsonData.url ==="https://www.v2ex.com/go/python"; 

其中JSON.parse()方法用于将一个 JSON 字符串转换为对象。

断言为了判断json中的id=90.url="https://www.v2ex.com/go/python"

postman可以完成

可以使用Python写脚本来实现

猜你喜欢

转载自blog.csdn.net/u013155359/article/details/84580362
今日推荐