Jmeter interface testing of multi-parameter passing

Interface testing comprising a single multi-interface interfaces testing and testing, to achieve a set of verification is called a multi-function interface test by combining a plurality of interfaces, the interface lies a single response to a single interface assertion request more combinations, a combination of different interfaces focusing multi-interface, for Inline and verification process. Multi-interface testing involves passing parameters between interfaces, two interfaces such as AB synergistic perform one function in response to the A interface as an input interface B, you need to use the associated function Jmeter here. This article provides two serial interfaces examples show how to apply the parameters passed Jmeter implement multiple interfaces.

The data association is a dynamic application acquired, save it as a parameter, to provide to the local need later be used, among transmission parameters may be achieved by associating the multi-interface. Jmeter commonly associate the two components:

Regular Expression Extractor

Json Extractor


 

Interface Example

Interface A: Enter the user name, password, create a user to return to the new user id

Interface B: user information input id, user name, user password, etc. for carrying out editing (B user id A new interface is based on the returned interface for data modification)

 

Regular Expression Extractor

Regular expression extractor is a post-processor, which can extract data in response to the request by the regular manner, the Jmeter regular expression extractor has the following options

Reference name: variable name stored in the matching result may be a value or may be a set of values

Regex: regular expression matching, regular expressions which can have multiple regular

Regular greedy and non-greedy pattern matching: greedy mode matches as much content, non-greedy mode matches as little as possible, the difference between greedy and non-greedy mode is whether there is a regular in the match?

Template: Regular expression extractor type, style is: $ n $, templates can be combined, spliced ​​to form a new string contents.

Template is $ 0 $, for the entire expression to match the content;

Template: $ 1 $, corresponding to the contents of the first regular expression in small brackets () matches;

$ 2 $ template, the regular expression corresponding to the content of the second small brackets () matches;

Template $ 2 $ $ $ 1, 2 put () stitching together the matched content, aa $ $ $ 1 $ 2 content splicing two variables, and in the middle with aa

Match numbers: -1 for all data fetch, 0 represents a random value, a representative of taking the first data, the second represents the data taken

When the value did not match Default:

 

Examples of regular expressions to extract

Get response packet port A

 


 

Based on the regular expression extractor Jmeter postprocessor prepared as shown below, it extracts the response packet id


 

View variable by debugSampler extraction results


 

A return to the use of the interface (new user) interface parameters B (modified users)

 

 


 

Json extractor

Json extractor is a post-processor, which can extract data in response to the request message by parsing Json manner, the Jmeter Json extraction has the following options

Variable name: variable name to store the extracted

Json Path Expressions: Json Path expression

Match Numbers: the number of matches, 0 represents a random acquired, represents the first data acquisition, -1 for all data acquisition

Compute concatenation var (suffix_ALL): whether to count all upcoming matches to save all the values ​​for the variables _ALL.

Default Values: No matching prompt information of value

Json Extractor extracted value is stored in a variable, and use common variables, referenced by $ {variable} Json Extractor can be. Variable names Json Extractor storage is based on the extraction of variables in the name of the extension, the proposed variable name by adding DebugSampler get Json Extractor actual stored value.

 

Examples extractor Json

Get response packet port A


 

Based on the prepared as follows Jmeter Json-processor extractor extracts a response message id


 

View variable by debugSampler extraction results


 

A return to the use of the interface (new user) interface parameters B (modified users)


 

 

Can be seen by the above example, the regular expression process flow extractor and extractor Json is the same, but different extraction methods. Jmeter can be resolved by adding the appropriate post-processor to request return result, and stored as the parameter for subsequent interface, the request to implement multiple parameters passed in this manner, thereby realizing a serial test interface.

Work's: Testfan Kitty

Source: micro-channel public number: automated software testing platform

Copyright: welcome to reprint, but must indicate the source and gives links to articles in the apparent position of the article page

Guess you like

Origin www.cnblogs.com/testfan2019/p/11528068.html