前言
postman 參數化導入csv 文件測試數據時,最后一條數據總是失敗,查看preview發現最后一條數據后面多了"\r"
問題描述:
postman 參數化導入csv 文件測試數據時,最后一條數據總是失敗
查看 preview 發現最后一條數據后面多了"\r"
解決辦法
先查看csv文件原始數據,用excel打開文件,看不出最后一個數據有什么不一樣
csv文件最好用編輯器去打開,比如:Notepad++
打開后發現最后一條數據多了一個空行,用其它編輯器如pycharm也能發現最后多一空行
解決辦法去掉最后一行的空行就行了,重新導入最后一個數據就正常了
更多解決辦法
如果上面的方法不能幫助你解決,可以查看官方文檔https://blog.postman.com/using-csv-and-json-files-in-the-postman-collection-runner/
CSV files
For CSV files to work inside the Collection Runner, the first row needs to consist of variable names
that you want to use inside requests. Every subsequent row is used as a data row.
Make sure the line endings of the CSV file are in the Unix format. That’s a restriction in our current CSV parser.
Line endings can be changed in a text editor like Sublime Text.
要使CSV文件在集合運行程序中工作,第一行需要包含要在請求內部使用的變量名。每個后續行都用作數據行。
確保CSV文件的行結尾為Unix格式。這是我們當前CSV解析器中的限制。可以在文本編輯器中更改行結束,如: Sublime Text
總結就是csv文件的編輯盡量用編輯器去編輯測試數據,最后一行不能多空行。