Postman+newman+jenkins Implementing API Automation testing

Source: Internet
Author: User

I recently learned to use Postman+newman+jenkins to implement API Automation testing, here to do a review and record. ( This is an environment built on Windows )

I. Description

1. General idea: Use Postman to do interface debugging the collection export. json file, then run the. json file with the Newman command and draw the test results, finally integrated into the Jenkins implementation automation.

2. Environment Note: Postman based on the JavaScript language, postman scripts (JSON files) run on Newman environments, while Newman environments rely on JavaScript's environment Nodejs.

Second, Nodejs installation

1. Download the installation package:https://nodejs.org/en/

   

2. Install: Directly click on the installer, next, wait for the program to complete; (Setup will automatically add the node environment variable to path)

Verify that the Nodejs is installed successfully, open the DOS command window, enter Node-v, and the version number is installed successfully.

      

Third, installation Newman

1.dos Command Window Input: NPM install-g Newman

  

2. Verify that the Newman is installed successfully, enter NEWMAN-V, and view the version number to install successfully

  

Iv. Installation of Postman

1. Download the installation package:https://www.getpostman.com/

  

2. Installation: Direct click on the installation program, next, wait for the program to complete the installation;

V. Postman Export. json file

1. Start postman, add interface access, enter the necessary parameters, click Send to confirm that the server return value is correct

  

2.Tests use: Tests you can add some assertions to determine whether the request was successful.

  

3. Export the. json file

Export file, select Address to save.

4.dos window to run the JSON file: Run the. json file in a DOS window first to see if the running results are sufficient to meet your expectations.

  

The Newman command can execute a. json file

Six, integrated Jenkins

Jenkins Build:

1. Download the installation package:https://jenkins.io/index.html

  

2.jenkins Installation: Click on the Installer and click Next to install.

3.jenkins after successful installation, local browser input: localhost:8080 (default 8080 port)

 

4. New Jenkins user, add HTML Publisher plugin plugin in System setup---management plug-in

5. Create a free-style item

  

6. Configure Jenkins:

Select the "Configure" option for item

  

Build option, select Add Build step, select Execute Windows Batch Command

  

Enter the Neman Run command, plus the command to generate the report

  

Added post-build actions: Add publish HTML reports and publish Junit test result report

"Post-Build Action"--publish HTML reports

  

Post-Build Action---Publish Junit test result report

  

Click Save. Jenkins's preparation is complete, and finally the node configuration.

System Management---Management node--Configuration

  

Immediately after saving, build

  

Viewing HTML reports

  

    

  

The above is the use of Postman+newman+jenkins on Windows to implement automated testing of the building of the API, follow-up Considerations on Linux implementation

  

  

Postman+newman+jenkins Implementing API Automation testing

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.