[英]Web test: how to filter matching data from a data source?
Noob question on web testing: In step 1 of my web test, I load a Foo
record, which has a value of Score
equal to 200. 关于Web测试的Noob问题:在Web测试的第1步中,我加载了Foo
记录,该记录的Score
值等于200。
In a datasource MyDataSource.csv
I have data like so: 在数据源MyDataSource.csv
我有如下数据:
Group No Value Description
1 100 Not so good
2 175 OK
3 250 Pretty good
4 300 Excellent
Based on the value of the Score
field, I want to set a context variable {{groupNo}}
for use in following steps, which is the group with the highest value that is less than or equal to score. 基于“ Score
字段的值,我想设置一个上下文变量{{groupNo}}
以用于后续步骤,该变量是具有小于或等于score的最大值的组。 So in our example, the groupNo
would be 2. 因此,在我们的示例中, groupNo
为2。
How do I do that? 我怎么做?
Solved my own question. 解决了我自己的问题。 I created an ExtractionRule
, and read the source data into a static collection. 我创建了ExtractionRule
,并将源数据读取到静态集合中。 In the Extract()
method, I looked up the appropriate value from that collection and wrote the appropriate value to a context parameter. 在Extract()
方法中,我从该集合中查找了适当的值,并将适当的值写入了上下文参数。
That's my workaround, though I'm open to accepting a different answer if anyone has a better solution. 这是我的解决方法,但是如果有人有更好的解决方案,我愿意接受其他答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.