当前位置:网站首页>JMeter connection database

JMeter connection database

2022-07-03 19:31:00 Xiaoqiang ~

First, introduce jar package mysql-connector-java-8.0.11.jar, Put in :\apache-jmeter-5.3\lib\ext Under the table of contents .

1. Create a new configuration component in the thread group :

 2. Fill in the above configuration elements : To connect mysql For example

Database URL:  jdbc:mysql://localhost:3306/student_info?charset=utf-8&useSSL=false&serverTimezone=UTC&allowMultiQueries=true

 3. Create a new thread in the thread group JDBC Request Sampler :

 4. Get the response result of the sampler , Response status code :

   Add to sampler Post Processors :beanshell Postprocessor ,

// Get the result information of the return sampler :

String response = prev.getResponseDataAsString();

// Get and return the sampler status code

String status = prev.getResponseCode();

// Output log information

log.info(response);

log.info(status);

// preservation 、 Take out the object

vars.putObject(" Object name ",Object);  # Save the object

vars.getObject("OBJECT_NAME"); # Take out the object

5. Use regular expressions to extract response result field values

  Check whether the extracted content is correct : You can add Sampler - Commissioning the samplers (debug-sampler)

5.1 Add... To the thread group BeanShell Sampler

Output the contents of regular expression :

log.info("msg1:"+"${msg1}");

6. Assertion - Response assertion :

6.1BeanShell Assertion :

String message ="${msg1}";

if(!message.equals("success")){

        Failure = true;

        FailureMessage = " Assertion failed ";

}else{

FailureMessage = " Assert success ";

}

In the view result tree, you can view the prompt of assertion failure

原网站

版权声明
本文为[Xiaoqiang ~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202150135126628.html

随机推荐