jmeter

后置处理器

json提取器

http://www.51testing.com/html/18/n-4461218.html

https://www.cnblogs.com/tudou-22/p/12579575.html

若需要多个条件过滤,需要&&连接多个条件,如下

$.data[?(@.schemaName!='performance_schema' && @.schemaName!='sys')].schemaName
$.data[?(@.JobStatus==3||@.JobStatus==4)]

线程组传参问题:

通过JSON提取器 获得的变量只能用于本线程。可以在该提取器之后新加一个BeanShell后置处理器将JSON提取器中的变量存入property

BeanShell后置处理器

可以直接写java脚本,实用性更强

https://blog.csdn.net/weixin_30859423/article/details/95674726?fps=1&locationNum=2

https://blog.csdn.net/evanzhang_z/article/details/102715619

逻辑控制器

while controller

在判断条件中如果引入变量需注意写法

${__javaScript(${My_value}<1)}
对字符串的条件判断语句 ${__javaScript('${orderid}'=='null')}
对数字的条件判断语句 ${__javaScript(${count}==0)}

https://blog.csdn.net/ccc135/article/details/80658346

 https://www.jianshu.com/p/c46f473f3a6e

beanbash

  • 数组
${allrdsClusterIDs}为json提取器获取的所有id

${allIDs_matchNr}为${allIDs}的数量
import java.util.Arrays;
int count = ${allIDs_matchNr};
String[] totalIDS = new String [count];
for(i=1;i<=count;i++){
    String a = vars.get("allIDs_"+i);
    totalIDS[i-1] =  a;
}
String arr = Arrays.toString(totalIDS);
log.warn("arr:"+arr);
vars.putObject("totalIDS",arr);
  •  json

需要在测试计划中添加jar包

import com.alibaba.fastjson.*;
String all_configs = vars.get("ClusterConfigs");
String ClusterName=vars.get("ClusterName");
JSONArray json_array_configs = JSONArray.parseArray(all_configs);
JSONObject object = json_array_configs.getJSONObject(0);

JSONArray json_array_updated_configs = new JSONArray();//只修改第一个参数back_log
for(int i=0;i<json_array_configs.size();i++){
    JSONObject  object = json_array_configs.getJSONObject(i);
    if(i==0){
        object.remove("value");
        object.put("value","${__Random(0,65535,)}");
        log.warn("修改的参数为:"+object.toString());
    }
    object.put("url","nerv/nerv-rds/"+ClusterName+"/Mysql/config/variables/dev/variables.json");
    json_array_updated_configs.add(object);
}
log.warn(json_array_updated_configs.toString());
vars.put("update_configs",json_array_updated_configs.toString());

 BeanShell后置处理程序

参数以空格分隔

脚本中通过bsh.args[0]获取。例如

String aa=bsh.args[0];

固定定时器

会在该接口执行前等待指定的毫秒数

JDBC连接

https://www.cnblogs.com/poloyy/p/13182706.html

 自带的函数

__RandomFromMultipleVars

linux中如何运行

https://www.cnblogs.com/jessicaxu/p/7555046.html

CSV data config

参数化JSON的数据

 json键值对需使用两个双引号包裹,如""key""

 

原文地址:https://www.cnblogs.com/Nora-F/p/12907278.html