Jmeter's assertion - Checkpoint

Jmeter in the assertion is equivalent to the checkpoint lr. For checking whether the test response data obtained in line with expectations for performance testing process to ensure data exchange in line with expectations.

The purpose of using assertions: add a layer to determine the mechanism of the return level request; because the request is successful, the result does not mean necessarily correct.

Use assertions:

added at a corresponding selected Sampler asserted (because of the different assertion checking the contents of different types); good response to check the contents of the configuration (according to the circumstances asserted, asserts some control panel without adding any content, such as XML Assertion) .

add an assertion the result listener (add the listener), through the "assertion results" to see if by assertions; for a request, if passed, will only result assertion request print the name of his party;

  If it fails, in addition to the name of the request, there will be reasons for the failure of his party (different types of assertions, different results).

PS: a Sampler can add multiple assertions, to add the appropriate assertions based on your inspection needs, when all assertions under Sampler are passed, then the request is considered successful.

The latest version 5.1.1 version, there are 13 assertion:

1, in response to the assertion

 

Here are the next pattern matching rules:

           Includes: return results include content you specify

           Matches: (check with Equals like much, could not understand what is the difference)   

           Equals: Returns the specified result consistent results with you

           Substring: the result is the result of the specified string

           No: do not match

           To test the model: that is to fill the result you specify (can fill multiple ), the buttons [Add], [Delete] is designated content management

Case #: Baidu search: Haha request.

1) Test Mode [fill in the following two values ​​match success]

View Results trees can be seen, the request succeeds, then the response data contains both data.

2) Fill two data in response to data not, failure to match the value [] as follows:

 

View Results tree to view the assertion failed, and suggesting that there is no matching data.

 

Summary: How no general assertion error, you can prove that the request was successful, and here's assertion lr role in checkpoint is the same.

2, json assertion

parameter:

JSON Path EXISTS the Assert:  . $ Json added field you want to check in the back.

Addittionally assert value: whether to add value assertions, assertions field values added value and return json compares equal to the specified value.

Match as regular expression:   whether to support regular expressions.

Expected Value:   Adding an assertion value.

Expect null:   the expected null value, the check will match result is null, the assertion.

Invert assertion:   inversion, if the above result is asserted true, check this assertion result is false;

                                       If the result of the above assertion is false, check this assertion result is true.

Case #: below the json request returns a string.

1) [] matches the specific value added json assertion Front matching, as shown below:

See the results tree, you can see the request succeeds.

 Fill value is asserted front444, the match fails, as shown below:

2) match the regular expression [] Match as regular expression must be on the hook.

Match succeeds example, 17 bits match, the word number and a *, where the asterisk applied to \ escape, as shown in FIG match:

匹配失败示例:改为16位数字,匹配失败:

3)【预期为null】

4)【取反】这里就不演示啦。

【规则】这里说下取json匹配字段的规则

  • $  根节点
  • @  现行节点
  • .  子节点
  • ..  不管位置,选择所有符合条件的
  • *    匹配所有元素节点
  • [,]  支持迭代器中做多选
  • ?()  支持过滤操作
  • []  迭代器的标示,子元素操作符
  • ()  支持表达式计算

3、大小断言

4、JSR233断言

5、XPath断言

6、HTML断言

7、MD5Hex断言

8、SMIME断言

9、XML Schema断言

10、XML断言

11、断言持续时间

12、比较断言

13、Beanshell断言

BeanShell之前关于定时器的随笔中有介绍过,是一种松散类型的脚本语言(这点和JS类似),一种完全符合java语法的java脚本语言,并且又拥有自己的一些语法和方法;

作用对象:针对sampler中的Bean Shell sampler而使用的断言

参数:

Name:断言的名字(可以用一个比较容易理解和分辨的名称)

Comments:注释(对这个断言进行一个解释,备注)

Reset bsh.interpreter before each call:在每次调用Bean Shell之前重置bsh.interpreter类(bsh.interpreter是Bean Shell脚本语言的一种类,也可以理解为一种解析器)

Parameters(String Parameters and String []bsh.args):String参数(String []bsh.args是主类main函数的形式参数,是一个String 对象数组,可以用来获取命令行用户输入进去的参数)

Script file:脚本文件(可以填入脚本文件路径)

Script(see below for variables that are defined):参照下文定义的变量(使脚本文件参照定义的变量来运行)

 

这里重点介绍了前两个断言,和beanshell断言,其他的还未用到,用到的时候再补充啦~~~

Guess you like

Origin www.cnblogs.com/wuzm/p/10955547.html