jmeter test results are written to a file

In the interface performance test, it is a tedious thing to prepare the relevant business data. Ensuring that the data is generated accurately and quickly can improve the efficiency of the performance test. We can test related business interfaces through jmeter and then write the results to a file or database, so that we can obtain the data required for pressure testing.

The jmeter version I am using is 3.3 and requires jdk version 1.8

A new http request

1 Added http header information management and http message body

    

 

Enter the header information and message body required by the http request as shown below:

http header information

Message body:

 

 

 

 

2 Click "Authentication Binding Card"->"Add"->"Assert"->"Response Assertion"

 

3 Click "Authentication Binding Card"->"Add"->"Listener"->"View Result Tree"

 

 

Two-parameterized data

1 Prepare the files that need to be parameterized

 

2 Click "Authentication Binding Card"->"Add"->"Configuration Components"->"CSV Data Set Config"

 

 

    * FileName: The name and path of the csv file
     * File Encoding: File encoding---- empty by default
     * Varible Names: Define the parameter names in the text file, which can be referenced as variables after definition
     * Ignore first line(only used if variable name is not empty): ignore the first line (only use variable name is not empty) ---- default is false, if it contains column headers set to true
     * Delimiter: delimiter --- between each parameter Separator, comma is generally used by default,
     * Allow Quoated data: Allow data quotes---
    * Recycle on EOF: The file ends the loop---- set to True, the cycle value is allowed
     * Stop Thread on EOF: Stop the thread after the file ends------ The default is false, if it is set to True, it will affect the file End the loop
     * Sharing Mode: Set whether the thread is shared - the default setting is All threads

 

Three preprocessing and postprocessing

As the name implies, pre-processing and post-processing are some processing that needs to be done before and after each request. Here we mainly introduce pre-processing and post-processing.

 

1 Preprocessing

"Authentication Binding Card"->"Add"->"PreProcessor"->"BeanShell PreProcessor"

 

parameterized variable

 

 operation result

 

2 Postprocessing

 2.1 Need to extract the token returned after the request

"Authentication Binding Card"->"Add"->"Post Processor"->"Regular Expression Extractor"

 

2.2 Write the returned result and the required content to the file

"Authentication Binding Card"->"Add"->"Post Processor"->"BeanShell PostProcessor"

  

 Write the code, add the file if it does not exist, use it if it exists. Files are appended.

import java.io.FileWriter;
import java.io.IOException;

String uid = vars.get("uid");
String mobile = vars.get("mobile");
String bankid = vars.get("bankid");
String idcard = vars.get("idcard");
String token = vars.get("tokenn_g1");
String content = uid+","+mobile+","+bankid+","+idcard+","+token;

String fileName = "E:\\test.txt";
FileWriter fw = new FileWriter(fileName, true);
fw.write(content);
fw.write("\r\n");
fw.close();

 

Four run the program to see the results

1 Set thread 20, the number of loops is forever, until the data is run out (related to the parameterized data configuration)

 

2 "Thread Group"->"Add"->"Listener"->"Aggregate Report"

 

 

 3 Go to the directory to view the file and generate a set of data that I need

 

 

 

Follow up:

The content of jmeter execution result is written to the database

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324991185&siteId=291194637