Jmeter - 如何将多个令牌从 http 登录请求传递到另一个 http 请求

Jmeter - How to pass multiple tokens from http login request to another http request

我目前正在为使用 jmeter 的多用户测试设计一个测试用例,我需要一些帮助。 这是场景: 假设我有 2 个不同的登录门户,每个门户上有 500 个不同的用户。我想登录、访问 getExamSchedule、startExam、getListQuestion、getOneQuestion、submitOneQuestion 和 finishExam,因此我为每个请求创建了一个新的线程组。每个线程有 2 个采样器(1 个用于入口 A,2 个用于入口 B)。 我的问题是我应该如何从登录线程传递多个生成的令牌,以便我可以使用不同的令牌访问线程的其余部分。而且每个 http 请求都有一些我需要提取的响应,以便在另一个线程上使用。我试图提取令牌和对 csv 文件的响应,但不知何故它不起作用。让我知道这种情况下是否有任何最佳实践。先感谢您!

so I create one new thread group for each request - 通常您应该只为虚拟用户的新逻辑组创建 separate/different 线程组,对于您的用例,我认为所有内容都可以在一个线程组中。

根据JMeter Documentation

Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

因此,如果您确实需要跨不同线程组传递值 - 您可以查看以下解决方案:

  1. __setProperty(), __threadNum() and __P() functions 组合如:

    • 设置属性:

      ${__setProperty(token_${__threadNum},${jmeter-variable-holding-the-token},)}
      
    • 阅读属性:${__P(token_${__threadNum},)}

  2. 使用Inter-Thread Communication Plugin