【发布时间】:2022-01-18 17:22:00
【问题描述】:
let body = response.body; // json after hitting the api using automation
con.query("Select * FROM accounts WHERE name= '"+(Response.name+"'"), (err,rows,fields) => {
if(err) throw err;
console.log('Fetch Query done successfully for accounts_master tables');
var string=JSON.stringify(rows);
console.log("STRING",string);
var json = JSON.parse(string); //json i need to compare with above.
console.log("NAMEEEE",json);
输出:-
{
id: 11,
name: 'manav',
description: 'hellllllo',
owner: 11,
}
我将在两个 json 中都得到这样的输出,而不是一一比较键值,我想将整个输出 json 与 DB 进行比较(我从 DB 中获取) 请告诉我同样的情况。
【问题讨论】:
-
目标是什么?它必须相等还是你想看到差异?
-
如果不相等,那么我想让测试用例失败,否则通过
-
好吧,看看我的答案。
标签: sql node.js json testing automation