JMeter implementation of HTTP interface test Introduction

Source: Internet
Author: User
Tags to domain

This article mainly focuses on actual combat, with our company's main application of the HTTP interface as the core explanation.

1. Open JMeter

Introduction to the main interface:

The main interface of JMeter is divided into status bar, menu bar, toolbar, Tree tab bar and content bar.

Status bar: The main version and release version of JMeter are displayed.

Menu bar: All features are included in the menu bar.

Toolbars: The buttons on the toolbar are found in the menu bar, which is the shortcut button for the menu bar's common functions.

Tree tab Bar: The Tree tab bar is typically used to display the label associated with the test case.

Content bar: With the Tree tab bar display, the tree tag click on which tab, the content bar displays the corresponding content and action.

2. Concurrent Request Simulation-----Thread Group

Performance testing is primarily intended to simulate a large number of concurrent requests. JMeter uses a thread group to simulate a scenario that has concurrent access by multiple users.

On the test plan, right-click the Add-->threads (Users) –> thread Group, add the test scene settings component, the interface test is generally set to 1 "threads", according to the number of test data set "number of cycles."

Thread Group Interface Description:

    • Name: You can set a personalized name for the thread group
    • Note: You can add notes to a thread group to mark
    • Actions to be performed after a sampler error: How to execute after an error, optionally continue with subsequent, stop execution, and so on.
    • Number of threads: is how many threads need to be set to perform the test.
    • Ramp-up Period (in Seconds): Used to tell JMeter how long to build all the threads. The default value is 0. If ramp-up period is not specified, that is, ramp-up period is zero, JMeter will establish all threads immediately. Assuming that ramp-up period is set to T-second, the total number of threads is set to N, JMeter will establish a thread every t/n seconds.
    • Number of cycles: determines how many times a thread should run the test.
    • Delay thread creation until needed: delay creation of threads until required
    • Scheduler: Select to configure startup time, immediate or scheduled time
3. test Scenario Environment parameter setting ——— HTTP request Defaults component

This component is useful when the system under test has a unique access to the domain name and port.

Unified configuration data when you change access to domain names and ports

HTTP Request Defaults Component Configuration page

4. Add the HTTP Header Manager component

The request header information often needs to contain tokens, session, type and other information.

5. Set the "HTTP Information Header Manager"

Set the default request header, you can add authorization bypass login authentication;

Set Content-type to specify the requested content type;

Set CharSet to specify the requested character set, etc.;

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

7. Set "HTTP request"

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. Add Checkpoints: Add "response assertion" on "HTTP request" corresponding to the tested interface

9. set up checkpoints

The existence of a regular expression for the corresponding result is added to the Settings page.

10. Adding listeners

Easy to see the results after running

11. View "Aggregated report"

    • Label: The name of the HTTP request that is defined
    • Samples: Indicates how many requests were made in this test
    • Average: Average response time for access pages
    • Median: Accessing the median response time of a page
    • 90% Line: 90% response time to access the page
    • 95% Line: 95% response time to access the page
    • 99% Line: 99% response time to access the page
    • Min: Minimum response time for access pages
    • Max: Maximum response time for access pages
    • error%: Number of bad requests/total number of requests
    • Throughput: Number of requests completed per second
    • Kb/sec: The amount of data received from the server side per second

About 90% Line:

A group of numbers is arranged from small to large to find his 90th number (if 12), then 90% of the array will be less than or equal to 12.

The response time used in the performance test will also make sense, i.e. 90% request response time will not exceed 12 seconds.

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.

JMeter implementation of HTTP interface test Introduction

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.