当前位置:网站首页>Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
2022-07-07 08:51:00 【Software testing】
Test coverage tools
Write test cases according to requirements documents and design documents in the test process 、 Perform the test ; For more comprehensive coverage , We may also need to understand the logic of the program under test , You need to consider the input and output of each function , Execution of logical branch code , At this time, our test execution is measured by code coverage .
Coverage is an auxiliary index to measure the test effect .
01、 significance
Analyze uncovered code , So as to deduce whether the test design is sufficient in the early stage , Whether the code not covered is the blind spot of test design , Why not consider ?
demand / The design is not clear enough 、 Wrong understanding of test design 、 Strategic abandonment caused by the application of engineering methods, etc , After that, the supplementary test case design is carried out .
Waste code detected in the program , You can reverse the confusion in code design , Reminder design / Developers sort out the logic of the code , Improve code quality .
High code coverage does not mean high code quality , But on the other hand , Low code coverage , The code quality will not be much higher , It can be used as one of the important tools to test self-examination .
02、 Tool comparison
Mainstream tools in the market Emma、Cobertura、Jacoco、Clover( commercial ).
Jacoco brief introduction
Jacoco Is an open source coverage tool , The target language is java. It can be embedded in Ant 、Maven in , Also provided EclEmma Eclipse plug-in unit .Jacoco Mainly through code injection ( namely Java Agent) Way to achieve the function of coverage .
Many third-party tools provide access to Jacoco Integration of , Such as :Sonar、Jenkins、IDEA, Download address :https://www.eclemma.org/jacoco/
01、 Coverage related concepts
Jacoco Support multiple coverage statistics , Include :
Line coverage (Lines): Measure whether each line of code of the program under test is executed , Determine whether at least one instruction in the standard line is executed .
Class coverage (classes)): Measurement calculation class Class file is executed .
Branch coverage (Branches,C1coverage): Measure if and switch Branch coverage of statement , Calculate the total number of components in a method , Determine what to do and what not to do Number of branches .
Method coverage (non-abstract methods): Measure the method execution of the program under test , Execution depends on whether at least one instruction in the method is executed .
Instructions covering (Instructions,C0coverage): The counting unit is a single java Binary code instructions , Instruction coverage provides information about whether the code is being executed , Measurement is complete Independent source format .
Cyclomatic complexity (CyclomaticComplexity): stay ( linear ) In combination , Calculate the minimum number of all possible paths in a method , The missing complexity also means measuring The trial case does not cover this module completely .
02、 Pile insertion and different pile insertion modes
What is pile insertion
Program pile insertion , The first is the J.C. Huang Proposed by the professor , It is to insert some probes into the program on the basis of ensuring the original logic integrity of the tested program ( Also known as “ detector ”, In essence, it is a code segment for information collection , It can be an assignment statement or a function call to collect override information ).
Through the execution of the probe and throw out the characteristic data of program operation , Through the analysis of these data , The control flow and data flow information of the program can be obtained , Then dynamic information such as logical coverage is obtained , So as to achieve the purpose of testing .
On-The-Fly and Offine Compare
On-The-Fly The pattern is JVM adopt -javaagent Parameter assignment jar File startup agent , The agent is in ClassLoader Load one class Judge whether to modify before class file , And insert the probe into class file , The probe does not change the behavior of the original method , Just record whether it has been executed .
Offine Mode is to stake the file before testing , Generate inserted piles class or jar package , Test the inserted pile class and jar package , Generate coverage information to file , Final unified treatment , Generate a report .
Offline The mode is applicable to the following scenarios :
The runtime environment does not support java agent
Deployment environment does not allow setting JVM Parameters
Bytecode needs to be converted to other virtual machine bytecode , Such as Android Dalvik VM
Dynamic modification of bytecode and other agent Conflict
Unable to customize user load class
The house needs to be built layer by layer , Knowledge needs to be learned at one point one . We should lay a good foundation in the process of learning , More hands-on practice , Don't talk much , The last dry goods here ! I stayed up late to sort out the stages ( function 、 Interface 、 automation 、 performance 、 Test open ) Skills learning materials + Practical explanation , Very suitable for studying in private , It's much more efficient than self-study , Share with you .
Get off w/x/g/z/h: Software testing tips dao
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
边栏推荐
- Mock. JS usage details
- Speaking of a software entrepreneurship project, is there anyone willing to invest?
- Greenplum 6.x build_ install
- [step on the pit] Nacos registration has been connected to localhost:8848, no available server
- ES6_ Arrow function
- 【微信小程序:缓存操作】
- 详解华为应用市场2022年逐步减少32位包体上架应用和策略
- PPT模板、素材下载网站(纯干货,建议收藏)
- Greenplum6.x监控软件搭建
- Gson converts the entity class to JSON times declare multiple JSON fields named
猜你喜欢
登山小分队(dfs)
Compilation and linking of programs
Lenovo hybrid cloud Lenovo xcloud: 4 major product lines +it service portal
平台化,强链补链的一个支点
ncs成都新電面試經驗
[Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
Implementation of navigation bar at the bottom of applet
21 general principles of wiring in circuit board design_ Provided by Chengdu circuit board design
【MySQL】数据库进阶之触发器内容详解
Markdown编辑器Editor.md插件的使用
随机推荐
go写一个在一定时间内运行的程序
selenium自动化集成,八年测试经验软测工程师,一篇文章带你学懂
How to realize the high temperature alarm of the machine room in the moving ring monitoring system
Newly found yii2 excel processing plug-in
对API接口或H5接口做签名认证
Required String parameter ‘XXX‘ is not present
联想混合云Lenovo xCloud:4大产品线+IT服务门户
Routing information protocol rip
为什么要选择云原生数据库
Tronapi-波场接口-源码无加密-可二开--附接口文档-基于ThinkPHP5封装-作者详细指导-2022年7月6日-新手快速上手-可无缝升级tp6版本
[Yugong series] February 2022 U3D full stack class 007 - production and setting skybox resources
What are the advantages of commas in conditional statements- What is the advantage of commas in a conditional statement?
POJ - 3616 Milking Time(DP+LIS)
Rapid integration of authentication services - harmonyos platform
Frequently Asked Coding Problems
Greenplum 6.x version change record common manual
Greenplum6.x搭建_环境配置
Mock.js用法详解
ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
Sign and authenticate API interface or H5 interface