我正在使用POSTMAN Client并尝试从csv文件中读取数据。作为PoC,我使用了以下端点url
https://www.googleapis.com/books/v1/volumes?q=Light八月
以下是我的代码
tests["Status code is 200"] = responseCode.code === 200;
postman.setEnvironmentVariable("requestBook", data.requestBook);
var response = JSON.parse(responseBody);
tests["Validate the title is correctly populated"] = /{{title}}/.test(response.items[0].volumeInfo.title);
tests["Validate the author is correctly populated"] = /{{authors}}/.test(response.items[0].volumeInfo.authors);
tests["Validate the publisher is correctly populated"] = /{{publisher}}/.test(response.items[0].volumeInfo.publisher);
tests["Validate the published date is correctly populated"] = /{{publishedDate}}/.test(response.items[0].volumeInfo.publishedDate);
tests["Validate the page count is correctly populated"] = /{{pageCount}}/.test(response.items[0].volumeInfo.pageCount);
tests["Validate the category is correctly populated"] = /{{categories}}/.test(response.items[0].volumeInfo.categories);
tests["Validate the amount is correctly populated"] = /{{amount}}/.test(response.items[0].saleInfo.listPrice.amount);
tests["Validate the currency code is correctly populated"] = /{{currencyCode}}/.test(response.items[0].saleInfo.listPrice.currencyCode);

失败了。当我检查我的csv文件时,它看起来很好
注意:当我点击预览时,所有数据都显示为双引号
答案 0 :(得分:1)
我找到了解决方案因此解决了。新代码是测试["验证标题是否正确填充"] = response.items [0] .volumeInfo.title === data.title;