【发布时间】:2021-04-13 16:53:37
【问题描述】:
我在 Jmeter 中创建了 API 测试并提交给 GIT 分支。 我所有的 JMeter 测试都是从 Jenkins 流水线作业中执行的。
问题: 在 Jmeter 测试中,我使用了一个 bean shell 采样器,它从 CSV 文件中读取数据。参考以下代码。
LineNumberReader lineReader = new LineNumberReader(new FileReader(new File("${csv}")));
String line = null;
int count = 1;
while ((line = lineReader.readLine()) != null) {
String[] Test_details = line.split(",");
props.put("Test_id_" + count, Test_details[0]);
props.put("scenario_id_" + count, Test_details[1]);
count++;
}
lineReader.close();
在上述脚本中,CSV 路径来自 Jmeter 中的用户定义变量 (csv = 'FilePath')
当我从 Jenkins 执行测试时,无法检索 CSV 文件中的数据并且测试失败。
注意:当我从本地计算机执行时,会检索 CSV 中的数据并通过测试。
从 Jenkins 执行时,CSV 路径下的用户定义变量中给出。 csv = apitests\src\test\jmeter\data\Testdata.csv
下面是文件夹结构 Folder Struture
【问题讨论】:
-
来自git 的弹出文本:此外,请勿将此标签用于涉及 Git 存储库的一般编程问题。