How to build an interface automation testing framework?

After more than a year of interface testing work, some new adjustments have been made to the old framework, many redundant functions have been deleted, and only the most basic interface structure verification, interface regression testing, and online regular inspection functions have been retained.

1. Evolution of the framework

  1. The interface UI has been optimized, and the painting style of the whole framework is suddenly different (the truth is that people rely on clothes and horses rely on saddles)

  2. Added virtual DNS switching technology

    <dependency>
        <groupId>io.leopard</groupId>
        <artifactId>javahost</artifactId>
        <version>0.3-SNAPSHOT</version>
    </dependency>
    

    The host information can be dynamically configured to flexibly switch the interface test environment
    Dns dns = new DnsImpl();
    dns.update(host,ip);

  3. How do I change the http request call layer to rest-assure  TesterHome
    , because rest-assured is also an encapsulated HttpClient, if it is just calling the entry, the advantage is not so obvious, but if you want to verify each node, then rest The advantages of -assured are still very obvious.
    However, the main verification structure of our platform, jsonpath verification has some problems with the processing of empty nodes, and the old JSonArray package is still used for processing.

  4. The framework abandons the verification of data and business logic.
    Our interface test cycle is very short. In order to complete the test task within a limited time, testers and the server develop test scripts in parallel. Using gray box testing can complete the structure, data, logical validation. (During the early trial of gray box testing, it was found that this method is more suitable for existing work, so the framework discards the verification of data and business logic)

  5. Provide some testing gadgets for business testing

2. Personal views on the automation framework

  1. Being able to do a good job and implement one or a few points is success
  2. It is successful if it can bring technical innovation, test quality or efficiency improvement to the test team
  3. Be sure to automate based on the company's internal status
  4. If team members want to achieve unified recognition and unified goals, the efforts of one person must not compare with the efforts of a group of people.
  5. When you see an opportunity, you must seize it, and then slowly implement it and move forward. If it is not feasible during the implementation process, you must change your path in time...

What the company values ​​is the result, not the process. . . . . But for team members, the process is important. After more than a year of hard work, our team has gradually transformed from the initial functional testing and automated testing to the current gray box testing and white box testing. A test development team that advances quality from a technical perspective.

But then again, the most important thing is to have a leader who supports you. It is the most difficult to start, especially in the early stage. It is recommended to pull the head of the team to the united front first, so that the follow-up work can proceed!

foreword

After a year of evolution, some new adjustments have been made to the old framework, many redundant functions have been deleted, and only the most basic interface regression testing and online regular inspection functions have been retained.

Added the virtual DNS switching technology

io.leopard
javahost
0.3-SNAPSHOT

can configure the host information according to the example, and switch the interface test environment flexibly
Dns dns = new DnsImpl();
dns.update(host,ip);

Replaced the http call layer TesterHome

Currently working on interface testing, combined with the status quo of the department, I have preliminarily organized and built an automated testing framework for APIs. Now I will share my ideas and framework structure with you. On the one hand, I hope to provide you with some references. On the other hand I also hope that everyone can give more comments so that the test framework can be improved~~

main purpose:

1. Use case management of each version
2. Structure verification, node data correctness verification
3. Simple business logic coverage
4. Regression testing of each version
5. Online environment monitoring and early warning
6. Help development and testing to quickly execute interface tests, positioning problem

General construction process:

1. The information involved in the interface is stored in the form of data structure.

1,对接口、接口的输入、输出参数进行数据存储(POST、GET)

考虑到接口返回值一般都较庞大、逻辑关系较复杂,如果单靠人工进行采集的话工作量非常巨大,为了缓解压力提供了通过json串解析输出结构的功能。

2. Associating test cases with interfaces (supports automatic and manual cases; normal and abnormal state verification)

将收集的输入、输出数据以树型结构展现,通过简单的勾选来完成测试用例的输入参数及预期输出结构进行关联生成测试用例。

除了支持对JSON结构的校验,同时集成了selenium,实现对返回值为HTML的页面进行规则校验的功能

3. The input parameters of the test cases are configurable and also support the association with the output parameters of the uplink interface.

可以配置上行接口,取得相应节点对应值,自动赋予当前用例接口参数。

比如有些接口需要在登陆或其他的情况下去操作,那么就可以配置上行接口,模拟登陆,然后取得登陆key,用key做为参数去执行用例。
也支持选取规则配置中预先定义好的规则参数

Fourth, the interface has multiple modes of execution.

提供多样的执行入口

将接口各用例的执行情况(接口耗时 、成功与否、失败原因、异常节点等)信息,记入日志管理模块,同时为测试人员提供测试结果查询页面,对测试结果做大体的分析,尽可能的帮助测试人员去定位接口中存在的问题。

对于频繁变动的接口,影响范围又比较模糊,完全可以以大版本进行自动化回归测试,排查影响范围,以减少人工遗漏。

5. Support various validation rule configurations (set, length, type, format, etc.)

除了对输出结果进行简单的规则验证外,也支持输入参数集合绑定,可以对集合内所有项进行循环调用、循环验证排查。

6. Daily inspection and online early warning function

当接口打上巡检标识后,系统就会每天定时自动排查接口;同时协助线上环境监控及预警,自动生成预警邮件抄送相关负责人。

1,所有测试人员都可以通过WEB页面对接口进行录入、测试、生成测试报告。
2,在HOST配置中加入测试、开发、生产的IP地址后,系统就可以根据人员自动执行不同环境下的测试任务。

 Finally: [Tutorials that may help you]

 

 The editor is keen to collect and organize resources, and record the process from stepping on the pit to climbing the pit. I hope that I can record what I have learned, the techniques used in actual work, learning methods, experience, and some pitfalls I have stepped on. I also hope that you, who want to do software testing, can avoid some detours through my sharing, and can form a set of own methods and apply them in practice.

So I set up a self-study group for software testing and development. Friends who are learning testing can click the small card below

Guess you like

Origin blog.csdn.net/m0_68405758/article/details/129780769