首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于Postman的数据驱动测试

基于Postman的数据驱动测试
EN

Stack Overflow用户
提问于 2017-05-14 19:37:03
回答 1查看 863关注 0票数 1

我正在使用邮递员客户端,并试图从csv文件读取数据。作为一个PoC,我在端点下面使用了url

8月份的https://www.googleapis.com/books/v1/volumes?q=Light

下面是我的代码

代码语言:javascript
复制
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文件时,它看起来都很好。

注意:当我单击预览时,我的所有数据都会以双引号显示。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-16 06:32:10

我找到了解决办法,因此解决了这个问题。新代码是测试“验证标题正确填充”= response.items.volumeInfo.title === data.title;

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43968078

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档