在 JMeter 中使用值列表中的请求值 [英] Use request value from list of values in JMeter

查看:22
本文介绍了在 JMeter 中使用值列表中的请求值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定我过去已经这样做了,但不知何故我不知道如何;-)所以,这是我的问题:

I'm sure I've already done this in the past but somehow I cannot figure out how ;-) So, here's my problem:

我正在尝试创建一个 JUnit 测试计划,在该计划中,每次迭代都会通过更改特定参数来修改 HTTP 请求.因此,例如在五次迭代中,我希望发出以下 HTTP 请求:

I'm trying to create a JUnit test plan in which a HTTP request is modified each iteration by altering a specific parameter. So, for example in five iterations I want the following HTTP requests to be made:

http://localhost:8080/test/foo.html?id=1
http://localhost:8080/test/foo.html?id=2
http://localhost:8080/test/foo.html?id=3
http://localhost:8080/test/foo.html?id=4
...

我想为测试计划全局配置标识符值,并在 HTTP 请求采样器中使用它们,如下所示:

I want to configure the identifier values globally for the test plan and use them within the HTTP request samplerer like this:

Path: /test/foo.html?id=${categoryId}

现在的问题:如何全局配置标识符值(我不想想使用StringFromFile)以及如何在采样器中引用它们?>

The question now: How do I configure the identifiers values globally (I do not want to use StringFromFile) and how do I reference them in the sampler?

推荐答案

有几种方法可以做到这一点.

There are several ways you can do this.

  • If you're only incrementing, you can use a counter element
  • You can use any number of functions to calculate the value
  • You can read from a CSV file, which is the same effect as "StringFromFile" but easier to customize and manipulate

如果您有一组值,您可以:

Given you have an array of values you could:

  • 试试预处理器 "User参数",创建一个条目对于每个用户/循环
  • 使用豆壳创建数组的脚本,选择随机一个并填充你的变量
  • Try the pre-processor "User Parameters", creating one entry for each user/loop
  • Use a Beanshell script to create the array, select one at random and populate your variable

您完全按照列出的方式引用它们:${varName}

You reference them exactly as you have listed: ${varName}

这篇关于在 JMeter 中使用值列表中的请求值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆