Learn more from Postman ->>>> Click here

Newman+Postman implements interface automation testing

Newman is a Postman nodeJS library that can directly run Postman’s exported JSON files on the command line.

Newman makes it easy to run test collections, batch execute API test cases and generate reports.

Install node.js, configure environment variables, and download from nodejs.org/en/. Open the command line, run: NPM install -g Newman, and check whether Newman -v is installed successfully

Newman Run json file [options]

Json -e xxx.postman_environment.json specifies the environment variable Newman run xxx.json

Json -g xxx.postman_globals.json specifies the global variable Newman run xxx.json

4. Generate test report in JSON and HTML format

newman run xxx.json -r test_report.html

This section describes how to use the Postman tool

Adding environment variables

Generally, the interface test and official site domain name address are added to facilitate switching between the test site and official site

Add global variables 1. Add fixed global variables

2. Add dynamic global variable parameters

Variable call format {{variable name}}, in the request address, request header, request parameters can call the variable value

Add assertion Interface assertion has three dimensions: protocol status code assertion, business status code assertion, and return parameter assertion

Built-in common scripts Common built-in assertion scripts

Other commonly used built-in scripts

Batch Running scripts

 

Export file The exported file in Postman is usually in JSON format

Export the interface test case set

Exporting environment variables

Exporting global variables

 

Newman run Newman run [export API set] -e [export environment variables] -g [export global variables] -r HTML

 

2, -r HTML specifies to generate test reports in HTML, JSON, and XML format and save them in the user -> Newman folder