Talk about how to use Postman for automatic interface testing

愿你我相遇,皆有所获! 欢迎关注微信公众号:【伤心的辣条】 免费领取一份216页软件测试工程师面试宝典文档资料。以及相对应的视频学习教程免费分享!

What is automated testing

A practice that transforms the testing behavior of people on software into the testing behavior performed by machines.

For example, GUI automated testing, simulating people to operate the software interface, liberating people from simple and repetitive labor.

The essence is to use code to test another piece of code, which is a kind of software development work. The used cases that have been developed must also be updated as the tested object changes. Therefore, there are additional maintenance costs.

What are the classifications of automated testing

Classification by test purpose

Functional automation test

Performance automated testing

Classification by test object

Web application testing

APP test

Interface test

unit test

Why do we need automated testing

  1. It can replace a large number of manual and mechanical repetitive operations, and test engineers can spend more time on use case design and new function testing

  2. Can greatly improve the efficiency of regression testing, very suitable for agile development process

  3. Can make better use of unattended time to perform tests more frequently

  4. It can efficiently implement certain types of tests that cannot be completed by manual testing or are costly, such as: system stability testing that runs continuously for 7*24 hours and stress testing of high concurrency scenarios

  5. It can ensure that the operations performed each time are consistent and repeatable, and will not be affected by human emotional factors.

Postman automated test demonstration

Everyone uses postman quite a lot, so I won’t introduce how to use it. If you need postman video information, please private message

1. Create a new collection

Just to classify the interfaces to be tested uniformly

2. New interface

Below is what I added

3. Fill in the automated test script

For example, I need to test a few points

1.http status code 200

2. The code code of the returned json is 0

3. The interface return time is not less than 1000 milliseconds, the script is as follows

//View httpCode code

tests["interface status code 200"] = responseCode.code === 200;

//Judging the request time

tests["Return time is less than 1000 milliseconds"] = responseTime <1000;

//Return body to json

var data = JSON.parse(responseBody);

//Check json data

tests['code must be 0']= data.code==0

The test results are as follows

4. Enter all interfaces

Then I want to perform such a test on all interfaces, and enter all these interfaces, as follows

5. Perform automated testing

Click the Run button of the collection

The following interface pops up, you can fill in the corresponding parameters, here I use the default

Click Run, the execution result is as follows

As you can see, we tested 32 interfaces, of which 25 passed and 7 failed. Some of them did not meet the time requirements, and some of them had incorrect status codes.

For this result, we can optimize the interface ourselves, it's that simple, light weight baby!

In addition, Postman also launched a command-line version of Newman, which can cooperate with Jenkins for automatic interface testing and continuous integration.

Finally: benefits given to testers

In the technology industry, you must improve your technical skills and enrich your practical experience in automation projects. This will be very helpful for your career planning in the next few years and the depth of your testing technology.

In the interview season of the Golden 9th and the Silver 10th, the job-hopping season, organizing interview questions has become my habit for many years! The following is my collection and sorting in recent years, the whole is organized around [software testing], the main content includes: python automation test exclusive video, Python automation details, a full set of interview questions and other knowledge content.


For software testing friends, it should be the most comprehensive and complete interview preparation warehouse. In order to better organize each module, I also refer to many high-quality blog posts and projects on the Internet, and strive not to miss every knowledge point. Friends relied on these contents to review and got offers from big factories such as BATJ. This warehouse has also helped many learners of software testing, and I hope it can help you too!

May you and I meet and you will find something! Welcome to follow the WeChat public account: [Sad Spicy Article] Receive a 216-page software test engineer interview book for free. And the corresponding video learning tutorials are free to share!

Guess you like

Origin blog.csdn.net/weixin_50829653/article/details/112851963
Recommended