当前位置:网站首页>字节跳动精准测试实践,SmartEye背后的设计逻辑

字节跳动精准测试实践,SmartEye背后的设计逻辑

2021-06-09 07:12:43 InfoQ

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"简介"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在移动互联网高度发展下,移动APP趋近于大型化,功能也趋近于复杂化,诸如各种国民级应用,功能\/玩法等迭代不停,其背后对应的研发协作团队也非常庞大。在此种场景下,依靠人力堆叠去保障产品质量,并非最优解,在软件规模达到某个临界点之后,问题逃逸将无法避免。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"字节跳动在代码覆盖率监测平台基础上,建立了SmartEye-智能化精准中台,帮助研发团队快速定位代码变更影响域,精准推荐测试用例\/自动化巡检任务,为业务减负,为研发团队提效。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"背景"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在日常的研发活动中,我们经常会遇到下列场景:"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"这次需要研发自测保障了, 我的用例集是不是全都有效覆盖了?"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"这次技术重构改动挺大的,会影响哪些已有功能?"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基础工具SDK有重大升级,我是涉及到的业务方,哪些功能需要测试验证?"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"版本要上线了,大家都走一下全量回归Case,测试重点在哪里?回归测试用例集全量执行是不是必要的?"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在项目研发团队中的每个同学质量标准是不是都统一了?"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"上述问题在产品快速迭代下会越来越突出,每一个软件工程师应该都经历过上述问题的“拷问”。在此背景下,精准测试也应运而生。精准测试是国内软件工业界首创的技术概念。近年来,随着国内工业界深入探索,精准测试已经有较为广泛的影响力和统一的认知。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"精准测试是质量工程智能化建设的重要趋势,为项目研发验收全流程建立公信力度量指标,解决用例与代码的双向关联,精准匹配和投放测试资源(人力\/机架),削弱\/打破项目规模增长与质量保障资源增长的强正相关关系。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"工作流程"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/b6\/b66be60329b9aaa0ea9549e01f9687d6.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"上述是字节跳动研发团队比较常见的研发流程,在这里我们把研发需求划分为5个阶段:开发、自测、测试、集成回归、上线。精准测试发生的区间主要在自测、功能验收测试和回归测试阶段。在这三个阶段的节点1、2、3,业务通过请求SmartEye服务,可以分别获取到自测推荐用例,功能测试推荐用例,回归测试推荐用例。其中,自测用例和功能测试推荐用例用于验证代码变动是否引起存量功能异常,将功能缺陷发现时机前置,为研发团队争取更多的修复时间。回归测试用例推荐用来精简回归测试人力,帮助业务节省回归测试人效。"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/19\/19397b1629c19bc5912d6f56db57e2fc.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"用例知识库"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我们前期先建设了基础代码覆盖率监测平台,收集程序运行时的动态代码覆盖率数据,以此为基础来构建用例知识库。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/45\/45adab7c9065c792a7b5ea0817db1fc4.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"用例录制"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"客户端手工用例"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/e8\/e801a07ed4e86c8c1ba31170c5099262.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"人工用例录制,利用内嵌到客户端的SDK,提供UI界面供用户进行录制操作,同时由SDK内部保障录制过程中数据清理,采集,上报。用例录制结束后由SDK对当次录制数据进行上报,服务端实时解析,落盘用例知识库,供后续数据分析推荐,并及时给予用户录制反馈。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"客户端自动化用例"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/f7\/f7007438283ad6dc5a95b427aa911007.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"自动化用例录制全流程无人工干预,录制时需要以单个用例为分割,记录单条用例的代码覆盖率数据和用例的关联关系。SmartEye结合客户端高级调试模式SDK,使用公司基础长链接服务控制自动机架的指定设备进行用例数据的录制\/停止,全流程自动化,可以以很小的成本,批量录制客户端自动化用例。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"用例结构化信息"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/55\/5543b32fd3ec4ebed78699dd68a4207b.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"用例索引"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"利用当前变动信息、调用链信息、覆盖率信息等基础能力,建设代码-用例的映射数据集,以索引形式存储海量用例,为测试用例推荐等上层服务产品提供数据基础。基于用例的关联方法、关联代码块、上下游调用链路以及对应覆盖率等信息,建设不同粒度不同版本的"},{"type":"text","marks":[{"type":"strong"}],"text":"调用信息-CaseIDs倒排索引服务"},{"type":"text","text":",直接支撑推荐引擎的用例召回功能;此外,服务适配用例录制接口,实现了用例录制->用例信息解析->用例信息入库->索引生成的全流程自动化处理,并支持双端、人工&&自动化用例的多维度用例独立存储。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/10\/108213f03d765d08c61f5cff306e2c64.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"推荐引擎"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"代码影响域分析"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"准确定位MR的代码变动信息及其代码调用上下游影响域,能够帮助后续精准测试准确分析与之关联的测试用例,提升测试充分性与问题拦截率。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/1d\/1d190b3035fac32539d983c4ad2ac75f.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我们利用公司CodeGraph平台的双端静态代码调用链分析能力与整体调用链路拓扑数据,完成基于MR的变动DIFF分析以及上下游调用链分析,并针对变动DIFF部分,完成代码变动率的统计。"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/fd\/fd0e39140511e208421587edcd34e029.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"关联用例召回与多样性平衡"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基于改动影响的边界范围,召回对应方法、代码块、调用链路关联的用例集合,聚合去重后生成用例召回集合;"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"用例召回集合中,存在大量冗余用例。为实现向线上高频调用模块的测试倾斜,增加多样性控制逻辑。"}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基于对应方法&&代码块的关联用例数、用例覆盖率以及线上热度归一化指标,生成对应方法&&代码块的多样性控制因子,并最终将该因子作用在用例排序与推荐集生成阶段;"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/d1\/d17219a1f77984bbaa9ccf17fa99e931.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"推荐集生成"}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"模型层"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在用例排序阶段基于用例与变动影响域内各方法&&代码块的关联信息、用例后验指标、用例多样性控制因子等多维度信息,通过机器学习用例排序模型,计算用例与本次改动的相关性得分;基于相关性得分进行用例排序,并结合业务方指定的推荐用例数量,完成用例的筛选,生成用例筛选集。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"策略层"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"针对底层代码关联大量测试用例、用例路径多样性不足等导致的测试冗余问题,通过向业务侧赋能,结合业务方的先验知识体系,利用用例定向投放、底层代码规避等策略,以更加贴近业务的策略形式,在保证测试质量的同时,进一步降低测试冗余,提升测试效率。"}]},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"整体方案"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/1f\/1f5fcbad30b6016dfbd9f1ab8915525a.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"使用效果"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,我们与火山客户端等研发团队一起,搭建了字节跳动精准测试平台Cover,致力于为公司内所有产品线研发团队提供标准的精准测试解决方案,期望在保证质量的前提下为业务提效。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"该平台已在火山、抖音、西瓜等团队客户端迭代流程中落地,并取得了不错的效果。其中一个典型业务线利用精准测试,在保证100%拦截全量测试用例可发现问题的基础上,提升人效约40%,具体数据如下:"}]},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/60\/605b2fe0171b2fb4d8f098ba61b63801.png","alt":"图片","title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"总结"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"目前,SmartEye精准引擎每日推荐用例数1K+,效率提升约40%。借助SmartEye的能力,业务可以精确评估变更影响,清晰代码变动之后需要测试\/回归的用例集。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"基于SmartEye的精准测试,在字节跳动的落地得到了很多团队的支持,包括火山、抖音、头条、基础架构等多个研发团队,业务落地当前正在持续推进中。后续重点,我们将延伸SmartEye的精准能力,覆盖各种类型的测试用例与测试需求,在更大范围内成为DevOps基础服务,为更多的研发团队提效。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我们相信,越来越多的智能化测试工具落地,将会加速质量工程领域的变革,推动国内质量工程技术水平走到全球质量工程工业界前沿。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文转载自:字节跳动技术团队(ID:BytedanceTechBlog)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"原文链接:"},{"type":"link","attrs":{"href":"https:\/\/mp.weixin.qq.com\/s\/wUrm8gycgLHhCSHbpG8Hkw","title":"xxx","type":null},"content":[{"type":"text","text":"字节跳动精准测试实践,SmartEye背后的设计逻辑"}]}]}]}

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://www.infoq.cn/article/UqNsUC3zm04ydWcjo132?utm_source=rss&utm_medium=article