我有一个json文件,如下所示,
{
"OrderRef": "Rand12345"
"siteContactName": "ABC",
"siteContactNumber": "12345678",
"contactMobileNumber": "12345678",
"estimatedDeliveryDate": "2016-03-08",
"orderLines": [
{
"productCode": "846581",
"productName": "ABC",
"quantity": 112,
"price": 5.01,
"vatAmount": 112.22
},
{
"productCode": "938169",
"productName": "DEF",
"quantity": 6,
"price": 45.03,
"vatAmount": 54.04
}
]
"orderNett": 831.30,
"orderVatAmount": 166.26,
"orderTotal": 997.56
}
我必须将此Json作为正文发送到帖子请求,我必须参数化OrderRef,productCode及其各自的ProductName。
所以我创建了2个文件,即orderref.csv和product.csv,其中orderref.csv有一个订单ID列表,product.csv有一个产品代码列表及其各自的名称。当我尝试这个时,
class Order extends Simulation {
val orderref = csv("orderref.csv").random
val product = csv("product.csv").random
val scn = scenario("OrderCreation")
.feed(orderref)
.feed(product)
.exec(http("OrderCreation")
.post("/abc/orders")
.body("""
{
"OrderRef": "${orderref}"
"siteContactName": "ABC",
"siteContactNumber": "12345678",
"contactMobileNumber": "12345678",
"estimatedDeliveryDate": "2016-03-08",
"orderLines": [
{
// ProductCode and ProductName are the headers of the columns in my product.csv
"productCode": "${ProductCode}",
"productName": "${ProductName}",
"quantity": 112,
"price": 5.01,
"vatAmount": 112.22
},
{
"productCode": "${ProductCode}",
"productName": "${ProductName}",
"quantity": 6,
"price": 45.03,
"vatAmount": 54.04
}
]
"orderNett": 831.30,
"orderVatAmount": 166.26,
"orderTotal": 997.56
}""").asJson)
setUp(scn.inject(atOnceUsers(1)))
}
我得到了
not found: value ProductCode
not found: value ProductName
但是orderref正在被接受。请提出任何建议。
谢谢