2017-05-14 72 views
1

我正在使用POSTMAN客户端并尝试从csv文件读取数据。作为在PoC,我用下面的终点URL数据驱动使用Postman进行测试

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

我找到了解决方案。新代码是测试[“验证标题正确填充”] = response.items [0] .volumeInfo.title === data.title; –

+0

写下此评论作为答案,而不是接受它。它将为您赢得一点名誉,并让其他开发者更容易看到答案。 – Ray

+0

我试过但找不到按钮说“回答” –

回答

1

我已经找到了解决方案,因此其解决。新代码是测试[“验证标题正确填充”] = response.items [0] .volumeInfo.title === data.title;