2017-05-14 76 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;