- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 JMeter 测试计划中获取线程和采样器名称并将其保存在变量中。
我已经使用 BeanShell 后处理器保留了测试计划名称:
import org.apache.jmeter.services.FileServer;
String testPlanName = FileServer.getFileServer().getScriptName(); vars.put("testPlanName", testPlanName)
最佳答案
共有三个函数,你可以在 BeanShell 中使用它们:
The
samplerName
function returns the name (i.e. label) of the current sampler. The function does not work in Test elements that don't have an associated sampler. For example the Test Plan. Configuration elements also don't have an associated sampler. However some Configuration elements are referenced directly by samplers, such as the HTTP Header Manager and Http Cookie Manager, and in this case the functions are resolved in the context of the Http Sampler. Pre-Processors, Post-Processors and Assertions always have an associated Sampler.
${__samplerName()}
The TestPlanName function returns the name of the current test plan (can be used in Including Plans to know the name of the calling test plan).
${__TestPlanName}
The thread group name function simply returns the name of the thread group being executed.
${__threadGroupName}
BeanShell
的完整详细信息, 请参见:
关于variables - 如何在 JMeter 中获取线程和采样器名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54442577/
我是一名优秀的程序员,十分优秀!