使用 Jmeter 的数据驱动方法

Data Driven Approach with Jmeter

我正在使用 CSV 数据集配置配置元素来读取 CSV 文件。我的要求是如果列值为 "Y" 则读取行,否则要跳过。

JSON Body 数据:

{
    "UserName": "${Username}",
    "Password": "${Password}"
}

CSV 文件内容:

Username,Password,RunTest
testuser,test@123,Y
testuser1,test@12,N

在请求前添加一个If Controller。在 条件 中,使用以下语法:

"${RunTest}" == "Y"

在运行时,如果值为Y,就会触发你的HTTP请求,否则不会。