当前位置:网站首页>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用法详解
- [Yugong series] February 2022 U3D full stack class 005 unity engine view
- Sign and authenticate API interface or H5 interface
- Rapid integration of authentication services - harmonyos platform
- Golan idea IntelliJ cannot input Chinese characters
- MySQL partition explanation and operation statement
- 阿里p8手把手教你,自动化测试应该如何实现多线程?赶紧码住
- 【踩坑】nacos注册一直连接localhost:8848,no available server
- [hard core science popularization] working principle of dynamic loop monitoring system
- uniapp 微信小程序监测网络
猜你喜欢
Data type - floating point (C language)
[Yugong series] February 2022 U3D full stack class 006 unity toolbar
Greenplum 6.x build_ install
Laravel8 uses passport login and JWT (generate token)
平台化,强链补链的一个支点
如何在快应用中实现滑动操作组件
Teach you how to select PCB board by hand (II)
关于基于kangle和EP面板使用CDN
21 general principles of wiring in circuit board design_ Provided by Chengdu circuit board design
let const
随机推荐
Appeler l'interface du moteur de création du service multimédia de jeu Huawei renvoie le Code d'erreur 1002, le message d'erreur: les paramètres sont l'erreur
Input and output of floating point data (C language)
调用华为游戏多媒体服务的创建引擎接口返回错误码1002,错误信息:the params is error
What are the advantages of commas in conditional statements- What is the advantage of commas in a conditional statement?
ES6_ Arrow function
opencv 将16位图像数据转为8位、8转16
Arm GIC (IV) GIC V3 register class analysis notes.
Componentspace2022, assertions, protocols, bindings, and configuration files
Greenplum 6.x build_ install
[machine learning] watermelon book data set_ data sharing
All about PDF crack, a complete solution to meet all your PDF needs
关于基于kangle和EP面板使用CDN
Tronapi wave field interface - source code without encryption - can be opened twice - interface document attached - package based on thinkphp5 - detailed guidance of the author - July 6, 2022 - Novice
Test pits - what test points should be paid attention to when adding fields to existing interfaces (or database tables)?
Teach you how to select PCB board by hand (II)
Sign and authenticate API interface or H5 interface
Greenplum 6.x monitoring software setup
实现自定义内存分配器
uniapp 微信小程序监测网络
登山小分队(dfs)