[英]How do i use csv variables inside of a jmeter groovy script?
I have a test plan with a csv data set config set up like so: CSV Data set Config我有一个带有 csv 数据集配置的测试计划,设置如下: CSV 数据集配置
My csv file looks likes: CSV file我的 csv 文件看起来像: CSV 文件
My JSR223 Assertions looks like: JSR223 Assertion我的 JSR223 断言看起来像: JSR223 断言
I want to use those values in DJ for my assetions.我想在 DJ 中使用这些值作为我的资产。 I tried using
vars.get("phmDownloadStatus")
and ${phmDownloadStatus}
inside of the groovy script but neither gets the value from the file.我尝试在 groovy 脚本中使用
vars.get("phmDownloadStatus")
和${phmDownloadStatus}
,但都没有从文件中获取值。 How do i go about using these values?我该如何使用这些值?
You have to specify the variable names inside your csv data set config.您必须在 csv 数据集配置中指定变量名称。 Add the variable names for each column in your csv file separated by a comma delimiter as below
为您的 csv 文件中的每一列添加变量名称,以逗号分隔符分隔,如下所示
Make sure to select ture
for ignore first line
as well if you are using headers.如果您使用标题,请确保为
ignore first line
选择ture
。
Now you should be able to use these values in your JSR223 Assertion.现在您应该能够在 JSR223 断言中使用这些值。
/t/3wso2.com/customers_3_1/1.0.0,3wso2.com,rkheSO1QK8DWLXKfYUJFrqXtHvAa,3bNiqxKVMAtpg9zdbcZQODP6qK4a /t/3wso2.com/customers_3_1/1.0.0,3wso2.com,f6inOQocRxm2qTmAkG3z9dNboOMa,CVsZlaVlg0WVlyqHc97bHQ6WCOca /t/3wso2.com/customers_3_1/1.0.0,3wso2.com,ZYJW0i02wSuyqlGB3WPWSvZGHYca,_cJLdQaeTo0j9gci5S2ELvaT_Yca
Your approach looks okayish, just make sure that your J_phmDownloadStatus
and phmDownloadStatus
JMeter Variables exist and have their respective anticipated values, you can check which variables are available for JMeter using Debug Sampler and View Results Tree listener combination您的方法看起来不错,只需确保您的
J_phmDownloadStatus
和phmDownloadStatus
JMeter 变量存在并具有各自的预期值,您可以使用Debug Sampler 和 View Results Tree 侦听器组合检查哪些变量可用于 JMeter
Just make sure:只要确保:
foo
and Foo
are absolutely different beasts from JMeter Variables perspectivefoo
和Foo
是完全不同的野兽${phmDownloadStatus}
as JSR223 sampler will cache the first occurrence and will use it for all subsequent iterations${phmDownloadStatus}
因为JSR223 采样器将缓存第一次出现并将其用于所有后续迭代
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.