HTTP API Interface Test Tool Postman Introduction

Source: Internet
Author: User
Tags postman interceptor

first, what is API interface testing?

There are several API interfaces that individuals divide into three categories.
The first is the function level, which tests the parameters of the interface, such as:
int GetResult (string key, string ID, int ticket).
The second is object-level, development in the use of API interface, the introduction of the package name, before using to declare an object, then you can use the method provided by the object, while testing, you need to test the functionality of the API and data input correctness. The second and the first difference is that we only need to focus on the interface provided to the user can be, do not care about the interface calls other functions, compared to the first, the granularity of the test is larger, the scope is smaller.
The third is the interface of the HTTP protocol, the app client and the back-end service connection, generally using the HTTP protocol, the client through the get and post methods to obtain data from the backend services. The third is more granular than the second, and we are concerned with fewer interfaces, but these interfaces are core functions.

second, why to test API interface?

The app backend service, when there is a feature abnormality, or spit out abnormal data, can cause the client function is abnormal, even crash phenomenon. The client crashes due to data problems, and if fault tolerance is not in place, the app can never start. This kind of harm to the user, to the company, is huge. It is therefore necessary to test the API interface.

third, how to test API interface?

There are many methods for testing API interfaces, such as: Use Fiddler to send Get, post function to verify. The downside is that after testing it again, it takes time to do it manually again during regression testing.
It is indeed a good idea to use Python's request for API interface testing, which is coded for API interface testing. But the problem is, time. There may not be time to do this script during the limited test time. If you complete this script, you need at least one round of manual testing to see what the expected return value will be.
Is there a tool that, after manual testing, does not need to write too much code and can immediately automate regression with the cases of functional testing?
Answer: Yes. Postman is the tool that can be used like a fiddler or a script.

    • Trial scope: test of HTTP API interface

    • Supported platforms for:windows& Mac OS

Construction of the environment
    1. Install Chrome Browser

    2. Open in the Chrome Address bar:Https://chrome.google.com/webstore/search/postman

    3. Add Postman and Postmaninterceptor
      Note:
      Postman is an independent chromeapp;
      Postman Interceptor can synchronize data with postman and send browsing history from Chrome to Postman.

    4. In the Chrome Address bar Open: chrome://extensions/, click "Details" under Postman, fill in the shortcut to the desktop.

    5. Start Postman and register an account.

Use of Postman

    1. Open the Postman Interceptor Sync switch in the Chrome browser

    2. Start post man, turn on the sync switch

    3. Visit Sogou homepage in Chrome browser and see the record of Access under Postman history tab

    4. Fill in a checkpoint.

① Select the request to check, such as: m.sogou.com, click the Send button to the right of the GET request, and in the body section you can see the returned data.

② Click on the tests at the bottom of the request section, and from the right checkpoint, select the point you want to verify, such as: Verify that the returned content contains "", click "Response body:contains string", and then add a row of check statements in the quarantine area, and change the string to be checked to " ”。 Then click Save to add the checked request to collections.

5. Collection of automatic run checks

① Click on "Collections" tab, select the Set up, click on the "Run" button of the collection to enter the test page. Select on the test page, Start test

6. The test results will be displayed in the Results tab on the right.

7. Postman supports a variety of different requests. From the Get list, you can select the type you want to test.

 use of Newman

In the correctness test, you can save all the test requests, which can be used in subsequent bug verification and regression. In the future, when the same module is being tested, the script that runs before it can complete the regression verification of previous functions.
Newman is a command-line tool that requires a npm,node environment to be installed on the PC. After the installation is complete, install Newman with the following command.

Once the installation is complete, you first need to save the script in postman to local and then execute it on the command line to generate the test report.

① Save the Postman collections to Local.

② executing postman scripts at the command line

③newman-c test.json.postman_collection–hresult.html

When the ④ runs, an HTML results page is generated.

The advantages of postman are:

1. Anyone can use, do not need coding ability;

2. The cases of function test can be changed into automation use case instantly;

3. Look at the return of the data, as with fiddler.

HTTP API Interface Test Tool Postman 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.