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:
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: 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:
|
<<: The principle and basic use of Vue.use() in Vue
>>: HTML set as homepage and add to favorites_Powernode Java Academy
Table of contents 1. Install Docker 2. Create a c...
Table of contents 1. Introduction 2. Use 1. @Comp...
1. Installation Instructions Compared with local ...
Use the FRAME property to control the style type ...
Table of contents 1. Two setState, how many times...
Table of contents How to display SQL log? ? Descr...
<br />User experience is increasingly valued...
Table of contents 1. Write an HTML, the first Vue...
This article shares the specific code of react+an...
I just started working a few days ago and install...
Achieve results html <div class="containe...
What is the main function of Docker? At present, ...
Table of contents 1. Start and stop service instr...
Prepare: MySQL 8.0 Windows zip package download a...
Table of contents 1. MySQL trigger creation: 1. M...