Apache JMeter是一款纯java编写负载功能测试和性能测试开源工具软件。
jmeter也可以用来做接口自动化
1,执行配置元件
2,前置处理器
3,定时器
4,取样器
5,后置处理程序
6,断言
7,监听器
1.http请求
2.java请求
3.数据库请求
把jdbc的包放到jmeter的lib文件夹下
4.webservice请求
在jmeter3.2版本之后,就不支持这种方式,但是可以用http请求实现
5.tcp请求
等等。。。
1.jmeter文本值传递,直接就是值,没有字段名。
线程数是指用户数
线程中的循环次数是指迭代次数
循环控制器的循环次数是相当于action中的for循环
2.参数化取值策略
All threads 唯一+每次迭代
Current threads 顺序+每次迭代
Current threads group 线程组内用唯一,线程组外用顺序。
区别
All threads 每个用户,每次取值都不一样。
3.参数编码格式
请求的编码格式在HTTP请求中配置
服务器返回的编码格式在jmeter.properties文件中配置
1.时间参数
${__time(yyyyMMddHHmmss,)}
2.随机参数
${__Random(100000000000001,999999999999999)}
jmeter关联是用正则表达式来实现
1.元字符
.
2.限定符
代表/语法 | 说明 |
* | 重复0次或者更多次 |
+ | 重复1次或者更多次 |
? | 重复0次或1次 |
{n} | 重复n次 |
{n,} | 重复n次或更多次 |
{n,m} | 重复n次到m次 |
用beanshell编写脚本实现
1 import java.io.*; 2 3 String fileName = "D:/xiaolin/jmetertest/data3/orderId1.txt"; 4 String result = "${orderId}"; 5 6 BufferedWriter out = null; 7 8 try { 9 File file = new File(fileName);
10 if(!file.exists()){ 11 file.createNewFile(); 12 } 13 14 out = new BufferedWriter(new FileWriter(file,true)); 15 16 out.write(result+ ",\n"); 17 18 out.flush(); 19 } catch (Exception e) { 20 e.printStackTrace(); 21 } finally { 22 try { 23 out.close(); 24 } catch (IOException e) { 25 e.printStackTrace(); 26 } 27 }
原文:https://www.cnblogs.com/cjxxl1213/p/12812567.html