MeterSphere做接口自動化測試時,遇到對json中數組的值進行斷言,就需要用到Beanshell後置腳本
1、腳本斷言json接口響應值
使用腳本對響應json格式資料進行斷言,判斷是否正确傳回
2、接口請求的json傳回值如下
{
"code": 0,
"data": {
"totalCount": 6,
"pageSize": 10,
"totalPage": 1,
"currPage": 1,
"list": [
{
"roleId": "1387354848344694786",
"roleName": "rolename77014191",
"roleDescribe": "角色描述",
"createTime": 1619606146000,
"permissionList": null,
"permissionIdList": null
},
{
"roleId": "admin",
"roleName": "管理者角色",
"roleDescribe"