APP下载

基于线上流量diff的快速接口自动化

2021-09-14闫耀珍

电脑知识与技术 2021年22期

闫耀珍

摘要:接口测试是软件系统测试非常重要的一个方面。某广告接口入参及出参众多,针对该接口进行日常测试时,需要执行的测试用例数量达到指数膨胀状态,且测试用例无法全面覆盖线上流量场景。在软件研发日益敏捷的时代,为了达到快速测试、场景覆盖度高这两大要求,基于unittest、DDT数据驱动测试框架等自动化测试用例组织技术,设计并实现了一套非常实用的接口Diff自动化测试框架。框架支持自动从线上服务器拉取所需的测试请求日志数据,通过在测试、线上两套环境中同时回放请求并收集返回结果,并以优美的Web页面展示测试结果报告。基于该框架的接口Diff自动化测试,能够在非常短的时间内高效完成日常测试,有效缓解了该广告产品因迭代频繁带来的巨大测试压力。

关键词:接口测试;unittest;数据驱动测试;Diff;请求日志

Abstract: Interface testing is a very important aspect of software system testing. Take an advertising interface as an example, there are many input params and output data, when test the interface daily, the number of test cases to be executed reaches an exponential expansion state, and the test cases can not fully cover the online traffic scenarios. In the era of increasingly agile software development, in order to meet the two requirements of rapid testing and high scene coverage, a very practical interface Diff automatic testing framework is designed and implemented based on the automation test case organizing technologies such as unittest and DDT data-driven testing framework. The framework supports automatically pulling the required test request log data from the online server, playing back the request and collecting the returned results in the test and online environments at the same time, and displaying the test result report in a beautiful web page. The interface Diff automatic test based on this framework can efficiently complete the daily test in a short time, and effectively solve the test pressure caused by frequent iterations of the advertising product.

Key words: interface test; unittest; data driven test; Diff; request log

1 背景

隨着现代互联网公司之间的竞争越来越激烈,用户需求也越来越多样化,对软件及服务更新速度和质量的要求也越来越高,如何通过加速产品研发流程,快速满足用户需求,使得在竞争加剧的时代赢得用户的青睐,成为企业关心的重要问题之一。举例来说,某广告业务为提升用户体验,间接提升收入,某后台服务已经达到了一天上线数次的频率,而在这种情况下,测试周期被不断压缩,于是对质量保障的速度以及质量提出了更高的要求。原有的手工回归测试至少也需要半天甚至更多的时间,并且回归测试能够覆盖的线上场景也非常有限,经常发生由于某个场景没有测试覆盖,导致出现线上问题,影响用户体验甚至收入。……

登录APP查看全文