Jmeter中的一些应用备忘

     正则表达式提取器中的模板和匹配数字是什么意思。

     匹配数字就是用来选择是哪一次匹配。

     模板是用来指定${变量名}时的输出格式的。

     从jmeter上摘抄的文字,

    

Suppose you want to match the following portion of a web-page:
name="file.name" value="readme.txt" and you want to extract both file.name and readme.txt.
A suitable reqular expression would be:
name="([^"]+)" value="([^"]+)"
This would create 2 groups, which could be used in the JMeter Regular Expression Extractor template as $1$ and $2$.

The JMeter Regex Extractor saves the values of the groups in additional variables.

For example, assume:

  • Reference Name: MYREF
  • Regex: name="(.+?)" value="(.+?)"
  • Template: $1$$2$
Do not enclose the regular expression in / /

The following variables would be set:

  • MYREF: file.namereadme.txt
  • MYREF_g0: name="file.name" value="readme.txt"
  • MYREF_g1: file.name
  • MYREF_g2: readme.txt
These variables can be referred to later on in the JMeter test plan, as ${MYREF}, ${MYREF_g1} etc


     另外,可以写一些简单的函数对结果进行检查。


JMeter functions are special values that can populate fields of any Sampler or otherelement in a test tree. A function call looks like this:

${__functionName(var1,var2,var3)}

Where "__functionName" matches the name of a function.
Parentheses surround the parameters sent to the function, for example ${__time(YMD)}The actual parameters vary from function to function. Functions that require no parameters can leave off the parentheses, for example ${__threadNum}.

If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter.For example:

${__time(EEE\, d MMM yyyy)}

Variables are referenced as follows:

${VARIABLE}

     在测试restful api的时候,需要加一个http头信息管理器,其中添加参数,content-type:application/json,这样可以支持发送json格式的内容给服务器。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值