Analysis of HTTP interface testing process based on postman

Analysis of HTTP interface testing process based on postman

I accidentally discovered a great artificial intelligence tutorial and couldn't help but share it with everyone. The tutorial is not only easy to understand for beginners, but also very funny and humorous, just like reading a novel! I think it’s awesome, so I’m sharing it with you all. Click here to jump to the tutorial.

There are many HTTP interface testing tools, and there are many ways to make HTTP requests, but they can be used directly, and the functions are well supported. From what I have used, Postman is easier to use.

advantage:

1. Support use case management

2. Support get, post, file upload, response verification, variable management, environment parameter management and other functions

3. Support batch operation

4. Support use case export and import

5. Support cloud storage use cases [Paid users]

It can be said that POSTMAN meets most of the functions of HTTP interface testing, and only a few functions are not supported, such as: control of request process; Having said so much before, let's take a look at the installation and use of POSTMAN.

1. What is POSTMAN

POSTMAN is a Chrome plug-in tool. We can search and install it through the Chrome app store. After the installation is complete, a postman icon will be displayed on the desktop. Each time you click this icon, you can start the POSTNA interface.

After startup, the above interface will be displayed. On the left is the directory structure used to manage use cases, and on the right are the request parameters and response content of a specific use case. The default postman comes with a demo project called "POSTMAN Echo", which contains use case demos for various scenarios. New students can learn how to use POSTMAN by viewing these demo use cases.

2. Create a new project

Simply click the Add Directory icon on the left column to add a root directory, which is equivalent to creating a new project. We can store the use cases of a project or a module under this directory, and we can also create subdirectories under the root directory to subdivide the functional use cases, as shown in the figure below.

2. Add a new use case

After creating the project directory, we can create a new use case. Specifically, click the + sign in the right area to add a template for an empty use case. You can also copy an existing use case to create a new use case. There are two methods as follows:

3. Add request information

The content of the newly created use case request is empty. We need to add the corresponding request information. The operations for this part are all in the information area on the right. The general process is as follows:

  • Select a request method, such as get or post
  • Fill in the requested URL, such as: http://www.baidu.com
  • If it is get, the request parameters are written directly after the url, using ? connect
  • If it is a post, the request is added in the body
  • Click "send" to send the request
  • View the request response content

4. Post request parameters

The main feature of a post request is to put the request data in the body instead of after the URL.

The above example uses the post method to transmit common parameters. If we need to send a request with a file, we need to change the request format as follows:

Please note that the contents marked in red boxes above must all match.

5. Add header information

Sometimes some specific header information is required when making a request. Postman can also perfectly support this. Just click the Headers tab to set the request header information.

6. Preprocessing and result checking

Preprocessing mainly involves setting some environment variables, which is equivalent to data initialization; as shown in the figure:

Response processing is to analyze and verify the response results, such as checking whether the code is 200, whether the content is equal to a specific value, whether it contains a specific value, etc.

Because both preprocessing and result checking use js as the scripting language, you can also perform any scenario that can be implemented by js to assist in testing.

7. Global variables and environment variables

We can assign global variables in the preprocessing and result processing script environments, and we can use them directly in specific test data. The specific usage is: {variable_key}}; For example, you can set global variables in the script:

postman.setGlobalVariable("username", "tester");

Then I can use it like this in the use case data item, { {username}} is used to represent the specific tester value, as shown in the figure below.

The setting of environment variables is basically the same as that of global variables, but we have another entry to set environment variables, that is, in the environment configuration management, we can pre-establish a set of variables related to the environment, and select the corresponding environment variable template before execution according to the actual test requirements, so that the environment difference between the test server and the online server can be quickly switched. For example: configure 2 sets of environment variable templates, one set of URLs is for the test environment, and the other set is for the online environment. We only need to select different environment variable templates according to different test objects, and there is no need to modify the URLs in the test data.

Above we extract the requested host, and then use different url values ​​in different environment variable templates. Later we can perform corresponding request tests by selecting different environment variable templates.

8. Export use cases as code

Another great thing about POSTMAN is that it exports use cases as CODE. That is, after you have written the use case, you can generate code with one click by clicking "Generate Code", and there are many languages ​​​​and libraries to choose from, which is great!

9. Batch execution use case

Finally, let's take a look at the batch execution function of POSTMAN. This function is handled by a separate runner. We need to operate it in another interface, as follows:

Click the buttons above in sequence and the runer interface will appear. Just click "Start Test" as follows

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Implementation of various types of value transfer in postman test interface
  • Postman interface to do the associated test method steps
  • Postman automated interface testing practice
  • Script test postman quick export python interface test process example
  • Springboot multiple file upload uses postman to test multiple file upload interface
  • How to use postman to test the interface (testing the user management module)
  • Graphical steps for batch execution of interface tests in Postman

<<:  The principle and basic use of Vue.use() in Vue

>>:  HTML set as homepage and add to favorites_Powernode Java Academy

Recommend

Native JS to implement paging click control

This is an interview question, which requires the...

Docker installation steps for Redmine

Download the image (optional step, if omitted, it...

Summary of MySQL ALTER command knowledge points

When we need to change the table name or modify t...

More Ways to Use Angle Brackets in Bash

Preface In this article, we will continue to expl...

Install Python 3.6 on Linux and avoid pitfalls

Installation of Python 3 1. Install dependent env...

Solve the problem of invalid utf8 settings in mysql5.6

After the green version of mysql5.6 is decompress...

MySQL permissions and database design case study

Permissions and database design User Management U...

SVG+CSS3 to achieve a dynamic wave effect

A vector wave <svg viewBox="0 0 560 20&qu...

MySQL isolation level detailed explanation and examples

Table of contents 4 isolation levels of MySQL Cre...

Analyze MySQL replication and tuning principles and methods

1. Introduction MySQL comes with a replication so...

How to add Lua module to Nginx

Install lua wget http://luajit.org/download/LuaJI...

An elegant way to handle WeChat applet authorization login

Preface When the WeChat mini program project invo...

Solution to the problem of insufficient storage resource pool of Docker server

Table of contents 1. Problem Description 2. Probl...