[Share] new dream dry Jmeter skills: Json data, how to set variables

I have two interfaces, A and B interfaces interfaces, B interfaces as follows:

New dream Share Dry



How to { "tag": { "name": "123456"}} value is the name behind the variable that is extracted from the A interface.

If a regular expression or json extractor, such as:


New dream Share Dry


Extracted values ​​directly in the B interface, such as: { "tag": { "name": "$ {tokens}"}}, the resulting return value will be { "tag": { "id": 149 , "name": "$ {tokens}"}}

Solution: json data format, can be stored in two forms of variables (Currently I know of), a helper function is a function of, for example:


New dream Share Dry

New dream Share Dry


Another external file is read from the outside, then into json data format, for example:


New dream Share Dry

New dream Share Dry

New dream Share Dry

New dream Share Dry


Remaining is very simple, since we know how to put data on the data json format, then the rest is how the data from the first interface on the extracted file, the following are examples:

First, we add a pre-processor or post-processor BeanShell PreProcessor BeanShell PostProcess, write scripts in it, the specific code as follows:

FileWriter fw = new FileWriter("E:\\tokens.csv",false);

BufferedWriter bw = new BufferedWriter(fw);

bw.write(vars.get("tokens")+"\n");

bw.close();

fw.close();

Probably means: now the local E: New this path tokens.csv file, under a cover on behalf of a false, if true, then write, representatives added later, after the new file, new bufferedWriter a target, vars.get retrieves the first interface with regular expression tokens extracted from the data, and then write the file, and then close both methods, must write close.

The overall process is a regular expression to extract the data, the processor stores the extracted data into the specified file, the original configuration data file CSV file in the setting data as variable speaking into json data format.


New dream Share Dry


Guess you like

Origin blog.51cto.com/14627097/2458460