How to use Postman for automated interface testing? 5 steps to help you achieve it easily!

What is automated testing

A practice that transforms human testing behavior of software into testing behavior performed by machines. For example, GUI automated testing simulates people to operate the software interface, liberating people from simple and repetitive labor. It is essentially using code to test another piece of code. It is a kind of software development work. Use cases that have been developed must also be tested. Updated as the object changes, therefore, there are additional maintenance costs.

What are the classifications of automated testing?

Classified by test purpose

  • Functional automated testing
  • Performance automated testing

Classification by test object

  • Web application testing
  • APP test
  • Interface testing
  • unit test

Why you need automated testing

  1. It can replace a large number of manual repetitive operations, and test engineers can spend more time on use case design and testing of new functions.
  2. It can greatly improve the efficiency of regression testing and is very suitable for agile development processes.
  3. Can make better use of unattended time to perform tests more frequently
  4. It can efficiently implement certain types of tests that are impossible or costly to perform manually, such as system stability tests that run continuously 24/7 and stress tests in 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.
现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

Postman automated testing demonstration

Everyone uses postman quite a bit, so I won’t introduce how to use it.

1. Create a new collection

It is just for the purpose of uniformly classifying the interfaces to be tested:

2. Create a new interface

Here's 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
//查看
httpCode码tests["接口状态码200"] = responseCode.code === 200;
//判断请求时间
tests["返回时间小于1000毫秒"] = responseTime < 1000;
//返回
body转jsonvar data = JSON.parse(responseBody);
//检查
json数据tests['code码必须为0']= data.code==0

The test results are as follows:

4. Enter all interfaces

Then I will conduct this test on all interfaces and enter all these interfaces, as follows:

5. Execute automated testing

Click the Run button of the collection:

The following interface pops up and you can fill in the corresponding parameters. Here I use the default ones.

Click Run, the execution results are as follows:

As you can see, we tested 32 interfaces, 25 of which passed and 7 failed. Some of them did not meet the time requirements, and some of them had incorrect status codes. In response to this result, we can optimize the interface ourselves, it's that simple.

Finally, I would like to thank everyone who has read my article carefully. Looking at the increase in fans and attention, there is always some courtesy. Although it is not a very valuable thing, if you can use it, you can take it directly!

Software Testing Interview Document

We must study to find a high-paying job. The following interview questions are from the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.

Insert image description here

Guess you like

Origin blog.csdn.net/m0_58026506/article/details/133101105