Using JMeter for HTTP interface testing

Source: Internet
Author: User
Tags http cookie

Objective:

This article is mainly for the HTTP interface testing, using the JMeter tool implementation.

The Jmter tool was designed for performance testing, and it has already done a good job of making calls to various interfaces, so this time use the JMeter tool directly to complete the test of the HTTP interface.

First, the development of interface test case of the overall scenario:

    • The first step: we need to analyze the test requirements, and get the development provided by the interface documentation;
    • Step two: The interface test cases are organized from the interface documentation to include detailed entry and exit parameters as well as clear formats and checkpoints.
    • Step three: Review the interface test case with the development.
    • Fourth step: Combine the development library, prepare the interface test case of the parameter data and the parameter data, and organize the file in CSV format.
    • Fifth step: The interface test case document and CSV format data document, to do interface test case development of automation cases.

Second, the interface Automation application scenario:

The current design of the automated interface test case has two operating scenarios:

1. Test the pre-development, self-testing: A new Automation Interface test case development, directly to the development of the interface, scheduling in the development of local environment execution, once the development of the completion of the interface development, the implementation of the interface test case, basically can get the test results in real-time, easy to develop rapid decision. "The way to develop local runs is to open the JMeter tool, import the Jmx file, and start execution." 】


2. Regression test: After the development of local testing, or the entire requirements after the manual test pass, the automated interface test cases are sorted, select the need to be included in the regression test cases, in the continuous integration environment to re-prepare test data, and the case into the continuous integration of the job, These interface test cases for regression need to be configured to run automatically on the continuous integration platform.

Three, interface test environment preparation

    • Jdk1.6 or above: http://www.oracle.com/technetwork/java/javase/downloads/index.html
    • Jmeter, download Address: http://jmeter.apache.org/download_jmeter.cgi
    • Plug-in Download installation address: http://www.jmeter-plugins.org/

Iv. creation of the project:

1. Open JMeter: After downloading good jmeter, double-click the Jmeter.bat file under the Bin directory:

  

  

  2. Add Thread group : Right-click on "Test Plan"-add-->threads (Users)--thread group, add Test Scene Setup component, interface test is generally set to 1 "threads", according to the number of test data set " Number of cycles ".

  

 3. Add "HTTP Cookie Manager ":

  

  

  4. Add the HTTP request Defaults component, which is useful when the system under test has a unique access to the domain name and port:

  

5. In the "HTTP request Defaults" Component Configuration page, fill in the domain name and port of the system under test, the implementation package version of the HTTP request and the specific protocol type, all "HTTP Sampler" in the thread group can use this setting by default.

6, add "HTTP request" sampler in "Thread Group"

  

7. In the HTTP Request Settings page, enter the details of the tested interface, including the request path, the corresponding request method, and the list of parameters sent with the request:

 8. Set checkpoint : On the "HTTP request" corresponding to the tested interface, add "response assertion"

9, on the Settings page to add the corresponding results of the existence of a regular expression judgment can be:

  

  10. Add Listener: easy to see the results after running

  

Operation Result:

  

The above steps complete the creation of a simple test case, and the complex test cases are expanded on this basis. Using the interface test case developed with the JMeter tool, a subsystem is proposed to be placed in the same "test Plan", and the process test can be differentiated by the "thread Group", which makes it easy to set the number of different test data. More independent interfaces can be uniformly placed within a group of threads and tested in sequence.   

Test of the process interface: if the interface to be tested can form a process, only the sampler of multiple "HTTP requests" is added sequentially, each request can extract the data that needs to be passed in the context as a parameter to ensure consistency of the data in the process.

Using JMeter for HTTP interface testing

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.