This article introduces a similarly more powerful tool: Postman
What is?
Developing APIs is hard, Postman makes it easy.
A powerful GUI platform to make your API development faster & easier, from building API requests through testing, documentation and sharing.
As you can see from the literal, is an API development test tool.
Make development more convenient, support HTTP request access test, document configuration, environment export share.
Postman provides a powerful Web API and debugging of HTTP requests. It can send any type of HTTP request (GET, POST, PUT, DELETE…). And can come with any number of parameters and Headers. Not only that, it also provides import and export of test data and environment configuration data, paying Post Cloud users can create their own Team Library for collaborative testing, and share their test favorites and use case data with the Team. Download and install 2. Simply use Postman THREE. Configure local environment variable four. Configure global environment variable 5. Configure the pre-request Script and Tests 6. Test favorites and use case data sharing
Download and install
Nothing difficult, go to the official website or their own Baidu, a lot of resources.
Website address: https://www.getpostman.com
Literally baidu first article: http://www.pc6.com/softview/SoftView_423615.html
2. Simply use Postman
Download and install, open the interface, try to initiate an HTTP request, in fact, very simple, the following visit Baidu as an example.
Configure local environment variables click Manage Environment in the upper right corner. Configuration local allows you to quantify some of the most commonly used values, and when it comes to variables, it’s easy, you know. 1. Reduce repeated operations. In the same environment, the same value is used in 10 places. Fast environment switch. In different environments, debug the same interface but different domain names. Switch environment variables to quickly switch the access address or other related parameters.
For example, I have the same variable {{domain}} in each environment, but the value is different in different environments. I switch the environment and seamlessly switch the corresponding domain name value. This is very helpful to switch the situation of many projects and many environments, otherwise it is very annoying to input back and forth for a while.
Configure global environment variables
As with configuring local variables, the entry is also in the upper right corner,
Global variables can take effect in any environment, such as the four environments [01,02,03,04] I configured, the configured global variables are valid, will not be invalid because of the switch environment.
5. Configure pre-request Script and Tests
Pre-request Script supports dynamic preparation of test data as embedded scripts and design of test cases based on business requirements.
Javascript script, if you can script access, you can solve a lot of problems, you know, a lot of things can be added to the logic, check, MD5 encryption.
[plain] view plain copy var date = new Date();
var create_date = date.getFullYear()+ ‘-‘ + (date.getMonth() +1 ) + ‘-‘ + date.getDate();
postman.setGlobalVariable(“create_date”,create_date);
Postman. SetGlobalVariable (” city “, “city”); / / set the global variable city has a value of “city” postman. SetGlobalVariable (” city_code “, “11”); Postman. SetGlobalVariable (” district “, “block”); postman.setGlobalVariable(“district_id”, “22”);
var sign =
‘city=’+postman.getGlobalVariable(‘city’)+
‘&city_code=’+postman.getGlobalVariable(‘city_code’)+
‘&district=’+postman.getGlobalVariable(‘district’)+
‘&district_id=’+postman.getGlobalVariable(‘district_id’)
//postman.setGlobalVariable(“sign”, sign.toString());
postman.setGlobalVariable(“sign”, CryptoJS.MD5(sign).toString());
Test favorites and use case data sharing You have written many use cases and interfaces, save them for the rest of the team to use, or back them up yourself.