如何在Postman工具中参数化日期格式以进行测试

时间:2018-05-16 14:08:26

标签: postman

以下格式在正文

"dateOfBirth":"[
1980,
6,
5
]",

我必须参数化(每次迭代必须更改(使用CSV文件))。

提前致谢

1 个答案:

答案 0 :(得分:0)

在我看来,你有两个选择:

  1. 您可以在CSV数据文件中将其分开,如: dateOfBirthYear,dateOfBirthDay,dateOfBirthMonth 1980,6,5 //1st iteration 1981,10,11 //2nd iteration etc. ...
  2. 您可以使用JSON,例如:
  3. [ { //here first iteration starts "dateOfBirth": [ 1980, 6, 5 ], "someOtherData: "string" },//here is the end of 1st iteration {//here second iteration starts "dateOfBirth": [ 1980, 6, 5 ], "someOtherData: "string" }//here is the end of 2st iteration ] (JSON中不允许发表评论)

    然后您可以在预请求脚本中使用它:

    var dateArray = data.dateOfBirth 但不要忘记这样的语法不起作用:{{data.dateOfBirth[1]}}(在Url f.e中)