Web Interface Test Tool--jmeter

Source: Internet
Author: User
Tags http post keep alive

About the JMeter Performance test tool is no longer described too much. If you want to learn software performance testing, then you should have heard about it.

It is highly recommended to read the official document Study: http://jmeter.apache.org/index.html

Is there a more authoritative, more comprehensive introduction to JMeter tools used?

however, It is used to do interface testing Here.

first, Install the Jmeter

Jmeter official homepage:http://jmeter.apache.org/

about the What Jmeter can do, the official also has a very detailed introduction. In addition its documentation is also written in Detail. If you want to learn Jmeter, then its documentation will be the best textbook.

I believe you can find it on the official website and download it.

Jmeter is developed by the Java language, and the latest version of Jmeter3.0 requires a Java 7 or later version of the Environment. I also believe you can handle the Java environment.

next, Unzip the downloaded Apache-jmeter-3.0.zip and go to the Unzip directory ... /apache-jmeter-3.0/bin . Double-click Apachejmeter.jar to start :

two . Add HTTP interface Test

our tools will be in the The Jmeter tool is completed, followed by the general steps to create an HTTP Interface Test.

for example, Right-click on "test plan"-"add"-"Threads (Users) " - "thread group".

For example, to set up a thread group, the thread group consists of three parameters: the number of threads, the length of preparation (ramp-up Period (in seconds)), and the number of Cycles.

Number of Threads : Number of Virtual Users. A virtual user occupies a process or thread. Set how many virtual users here is the number of threads Set.

Preparation Time : Set the number of virtual users to start all the time . If the number of threads is ten(seconds) , then it takes ten seconds to start a Thread. that is, an average of 2 threads per second is started .

Number of Cycles : Each thread sends a number of requests . If the number of threads is , and the number of cycles is three , then each thread sends a request. The total number of requests is 20*100=2000 . If " forever " is checked,then all threads will continue to send the request, straight to the Stop button on the toolbar manually, or to the end of the thread time Set.

because the interface test is done here, each parameter is 1.

for example, Right-click on "thread group"-"add"-"Sampler"- "HTTP request".

name : This property is used to identify a sampler and it is recommended to use a meaningful name.

Notes : No effect for testing, only user-readable annotation information is Logged.

server name or IP : The destination server name or IP address sent by the HTTP request .

Port number : The port number of the destination server, and the default value is .

Protocol : Sending to the destination server the protocol for HTTP requests, which can be HTTP or HTTPS , and the default value is http .

Method : Send Methods of HTTP requests, including GET,POST,HEAD,PUT , OPTIONS , TRACE , DELETE and so On.

Content Encoding : The encoding of the content, the default value is iso8859

Path : Target URL path (not including server address and port)

Automatic redirection : If this option is selected, when sending When the response received after the HTTP request is 302/301 ,JMeter automatically redirects to the new Page.

use Keep Alive : When this option is selected, HTTP is used keep-alive between thejmeter and the target server communication, selected by Default.

use multipart/from-data for HTTP POST : When sending HTTP POST requests are sent using the use multipart/from-data method, which is unchecked by Default.

send parameters along with the request : Send in RequestURLparameter, for parameters with theURL,JMeterprovides a simple way to parameterize. Users can addURLall parameters in this table, each row in the table is a parameter value pair (correspondingRULin the name1=value1).

for example, Right-click on "thread group"-"add"-"listener"-"view result tree".

third, Add a new POST request

The POST request is added in the same way as the previous GET Request. However , the POST request requires setting Parameters.

server name or IP: 127.0.0.1

Port Number:8000

method: POST

path:/polls/question_vote/

Send parameters together with the Request:

Click the "add" button to add the parameters for the POST Request.

Name :

Value

Qid

1

Cid

1

To perform the test:

Select the menu bar "run"-"clear", or click the toolbar to clear the Button. Then re-execute the Startup Test. and view the result Tree.

Iv. Adding assertions

For automated testing, assertions have to be made, and if there is no assertion that we can only compare the data returned to the interface by the human eye, the assertion function simplifies the process. Jmeter provides a wealth of assertion methods to help us do this Work.

as , right-click HTTP Request "add" - "assertion" - "response assertion".

response fields to Test: response text, Document (text),URL sample, response information,Response Headers,lgnore staus and other Options. Although the interface returns Json -formatted data , the return data is text for Jmeter , so you can tick "response text" here .

pattern matching rules: include, match, Equals,Substring. This only needs to verify that the return data contains the primary keyword, so check "include" here.

the pattern to test: is actually the asserted Data. Click the "add" button to enter the data you want to Assert.

To run the Test:

clear the test data again, Click Start test, View the result tree, as .

=====================

Interface testing is so simple!

Web Interface Test Tool--jmeter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.