Jmeter csv 参数化驱动时 不按文件数据依次读取,真的没辙了 。
这是文件数据:
offlineBarcode sku
6921734968173 10806
416885552 10808
416885553 10809
416885554 10810
416885555 10811
2200097003001
0000001347
0000000001
0000000002
0000000003
0000000004
报错数据1:
{"success":false,"code":"CART200202","msg":"商品不存在416885552","data":{"failureWarePrevent":0,"failureWareList":[{"offlinebarCode":"416885552","skuId":10808,"name":"416885552","failureMsg":"商品416885552不存在","count":1,"uuid":"5807c1e8-8872-4738-a8e6-d885cfdf5a89","failureRealMsg":"商品不存在","shortDisplayMsg":"商品不存在","unitOriginPrice":0}]},"tid":"1a1a2ece2a27ef90"}
报错数据2:
{"success":false,"code":"CART200202","msg":"商品不存在416885552","data":{"failureWarePrevent":0,"failureWareList":[{"offlinebarCode":"416885552","skuId":10809,"name":"416885552","failureMsg":"商品416885552不存在","count":1,"uuid":"5fdc7a35-98fb-49e7-a926-84e71090d255","failureRealMsg":"商品不存在","shortDisplayMsg":"商品不存在","unitOriginPrice":0}]},"tid":"bb49daa73b005b2"}
报错数据3:
{"success":false,"code":"CART200202","msg":"商品不存在416885552","data":{"failureWarePrevent":0,"failureWareList":[{"offlinebarCode":"416885552","skuId":10810,"name":"416885552","failureMsg":"商品416885552不存在","count":1,"uuid":"9b868b0f-acb0-4c02-a572-15fafafe9c43","failureRealMsg":"商品不存在","shortDisplayMsg":"商品不存在","unitOriginPrice":0}]},"tid":"ca7781495d694dfa"}
报错数据4:
{"success":false,"code":"CART200202","msg":"商品不存在416885552","data":{"failureWarePrevent":0,"failureWareList":[{"offlinebarCode":"416885552","skuId":10811,"name":"416885552","failureMsg":"商品416885552不存在","count":1,"uuid":"68ab09b2-8c7e-4ebb-9d3b-0b248574b1fa","failureRealMsg":"商品不存在","shortDisplayMsg":"商品不存在","unitOriginPrice":0}]},"tid":"97183075b72eac7b"}

以下是动态参数:
// 2. 创建主请求结构
def requestMap = [
// baseInfoReq: [supportCalculateMemberPromotion: true],
cashierId: ${cashierId},
cashierName: ${cashierName},
cashierNo: ${cashierNo},
channel: ${channel},
deviceCode: ${deviceCode},
deviceId: ${deviceId},
newWeighingCountsFlag: 1,
nonceStr: UUID.randomUUID().toString().replaceAll('-', '').substring(0, 16),
orgId: ${orgId},
platform: ${platform},
posNo: ${posNo},
// proDeductToken: "",
qrcode: "",
storeId: ${orgId},
tenantId: ${tenantId},
traceId: UUID.randomUUID().toString().replaceAll('-', ''),
venderId: ${venderId},
//version: ${version},
wareInputList: []
]
// 6. 构建商品列表
def wareItem = new HashMap()
wareItem.changeWeight = 1
log.warn("offlineBarCode:" + "${offlineBarcode}")
wareItem.offlineBarCode = "${offlineBarcode}"
//判断是否不为空 不为空则为国条码需要 saleMode、skuId字段
if (StringUtils.isNotBlank(vars.get("sku"))){
wareItem.saleMode = 10
wareItem.skuId = vars.get("sku") as long // 转换为数字类型
}
requestMap.wareInputList.add(wareItem)
//vars.put("offlineBarcode", "")
log.warn("requestMap:" + requestMap)
log.warn("offlineBarcode1:" + "${offlineBarcode}")
Map paramMap = JSON.parseObject(JSON.toJSONString(requestMap), SortedMap.class, Feature.OrderedField);
String sign = "";
boolean isBaseDataType(Class clazz) {
return (clazz.equals(String.class) || clazz.equals(Long.class) || clazz.equals(Integer.class)
|| clazz.equals(Byte.class) || clazz.equals(Double.class) || clazz.equals(Float.class)
|| clazz.equals(Character.class) || clazz.equals(Short.class) || clazz.equals(BigDecimal.class)
|| clazz.equals(BigInteger.class) || clazz.equals(Boolean.class) || clazz.equals(Date.class)
|| clazz.isPrimitive());
}
try {
StringBuffer sb = new StringBuffer();
for (String key : paramMap.keySet()) {
Object value = paramMap.get(key);
if (value == null) {
continue;
}
String valueStr = null;
if (!isBaseDataType(value.getClass())) {
valueStr = JSONObject.toJSONString(value);
} else {
valueStr = String.valueOf(value);
}
if (StringUtils.isBlank(valueStr)) {
continue;
}
sb.append(key);
sb.append('=');
sb.append(valueStr);
sb.append('&');
}
sb.append("key=" + ${dm_key});
sign = DigestUtils.md5Hex(sb.toString()).toUpperCase();
} catch (Exception e) {
throw new Exception("签名异常", e);
}
vars.put("sign", sign);
vars.put("param", JSONObject.toJSONString(requestMap));