当前位置:网站首页>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 .
边栏推荐
- Three usage scenarios of annotation @configurationproperties
- POJ - 3784 running medium
- Tips for using jeditabletable
- 【踩坑】nacos注册一直连接localhost:8848,no available server
- Data type - integer (C language)
- Greenplum6.x监控软件搭建
- Interpolation lookup (two methods)
- Greenplum6.x-版本变化记录-常用手册
- 实现自定义内存分配器
- Routing information protocol rip
猜你喜欢
ncs成都新电面试经验
idea里使用module项目的一个bug
[Yu Yue education] basic reference materials of electrical and electronic technology of Nanjing Institute of information technology
Interpolation lookup (two methods)
leetcode135. Distribute candy
Greenplum 6.x common statements
Greenplum 6.x build_ Environment configuration
ESP32-ULP协处理器低功耗模式RTC GPIO中断唤醒
Greenplum6.x重新初始化
Rapid integration of authentication services - harmonyos platform
随机推荐
阿里p8推荐,测试覆盖率工具—Jacoco,实用性极佳
[Chongqing Guangdong education] accounting reference materials of Nanjing University of Information Engineering
南京商品房买卖启用电子合同,君子签助力房屋交易在线网签备案
Greenplum 6.x common statements
[step on the pit] Nacos registration has been connected to localhost:8848, no available server
Upload an e-office V9 arbitrary file [vulnerability recurrence practice]
All about PDF crack, a complete solution to meet all your PDF needs
RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
[Chongqing Guangdong education] organic electronics (Bilingual) reference materials of Nanjing University of Posts and Telecommunications
Greenplum6.x搭建_安装
Implementation of navigation bar at the bottom of applet
Data type - floating point (C language)
Greenplum 6.x version change record common manual
Nanjing commercial housing sales enabled electronic contracts, and Junzi sign assisted in the online signing and filing of housing transactions
Test pits - what test points should be paid attention to when adding fields to existing interfaces (or database tables)?
Explain Huawei's application market in detail, and gradually reduce 32-bit package applications and strategies in 2022
QT charts use (rewrite qchartview to realize some custom functions)
Shell script for changing the current folder and the file date under the folder
Mock. JS usage details
阿里p8手把手教你,自动化测试应该如何实现多线程?赶紧码住