Chapter IV jmeter: Use extractor

Chapter Summary

The interface tests need to be verified is determined, then it is necessary to extract the return value, JMeter provides two methods:
a regular expression extractor, two, JSON extractor. This chapter will explain the two extracts is

First, the regular expression extractor

Step: Right "HTTP Request" -> Add -> postprocessor -> regular expression to extract
Here Insert Picture Description
Here Insert Picture Description
the following regular expressions meaning of each parameter value:

  1. Reference name: the HTTP request and the like, refer to this data, the need to use the name
  2. Regular expressions: the need for data extracted from
  3. Template: $ 1 $ this is a fixed format
  4. Match Value: 0 represents a random value, represents a first value, n represents the n-th value
  5. Default: If the regular expression search to no value, this default value is used

Regular regular expression format: string "token": "(.? +)" Digital form "taken": [(0-9) +]
() mark the beginning and end position of a sub-expression. Sub-expressions can be obtained for later use. To match these characters, use (and).

  • Matches the preceding subexpression one or more times. To match the + character, use the +.
    . In addition to matching newline \ any single character other than n. To match. Please use.
    ? Matches the preceding subexpression zero or one, or specify a non-greedy qualifiers. To match? Characters, use?.

jmeter understand the logic of these regular enough, I want to learn more: https://www.runoob.com/regexp/regexp-syntax.html

Two, JSON extractor

Step: Right "HTTP Request" -> Add -> postprocessor -> JSON extractor
Here Insert Picture Description
Here Insert Picture Description
following is the meaning of each parameter value extractor JSON:

  1. Reference name: the HTTP request and the like, refer to this data, the need to use the name
  2. Extraction format: $ data [0] .name
  3. Match Value: 0 represents a random value, represents a first value, n represents the n-th value
  4. Default: If the regular expression search to no value, this default value is used

json json format extracted explain:

  1. json string [] denotes an array of objects, {} represents an object.
  2. Object contains a number of "property": property value. Property value may be a value, or an array, or object.
  3. JSON Extractor using json path expression matching can take a plurality of variable values. $ Root object represents the response. Attribute takes a child object or objects. Take the object with the array [] array index starts from 0.

Examples:
. 1, $ .data [0] .name data field name in a savings Dir
2, name field in the Data .data.name $
. 3, .data $ [. 3] .name [2] .id savings data name in the fourth savings, id field under a third of the savings in the support
4, $. data.name [. 1] in the name field .id data, a second branch in this field id field under

Third, the method calls the various fields or parameters

Call format: $ {name}
area of use:

  1. Regular expression to extract the value of call
  2. JSON calls to extract value
  3. Calling user-defined parameters
  4. Assistant function call to set value
  5. Database to extract the value of call

Local calls are basically used this format

Guess you like

Origin blog.csdn.net/han20190223/article/details/91586380