当前位置:网站首页>Jacobo code coverage
Jacobo code coverage
2022-07-07 15:22:00 【Proud cat sauce】
Original address :
jacoco Instructions for incremental solutions _dray_ The blog of -CSDN Blog _jacoco The incremental
jacoco: jacoco Second opening , Support incremental code coverage
One 、Jacoco brief introduction :
JaCoCo It's an open source Java Code coverage tools .
JaCoCo Only the coverage of full code is counted , During code iteration , For example, it was modified bug, Another version of the code has been released .JaCoCo The statistics of are cleared , Trigger code coverage needs to be performed from scratch .
This scenario , We just need to test the incremental code , It's time to be right about jacoco Secondary development .
jacoco Count code coverage , Generally, it is combined with automation , such as jacoco Combined with interface automation . At that time, we can also perform it manually case, To count code coverage .
Can be embedded into Ant、Maven in ; It can be used as Eclipse plug-in unit , You can use it JavaAgent Technical monitoring Java Procedures, etc .
Many third-party tools provide access to JaCoCo Integration of , Such as sonar、Jenkins etc. .
Two 、 Code coverage introduction :
Coverage is used to measure the test of test code to function code . Through statistics, test the lines in the function code 、 Branch 、 Class and other simulation scenarios , To quantify the adequacy of the test .
Code coverage = Code coverage , A measure .
Coverage is simple : Ran a test case , Those modules in the project code 、 file 、 class 、 Method Yes .
The row coverage is the finest granularity , Other coverage rates can be calculated from the row coverage rate .
2.1 Line overlay
When at least one instruction is specified Source line Execution time , The source line is considered to have been executed .
Generally speaking, it means , Test behavior , Triggered this line of code , Then this line of code is covered .
2.2 Branch coverage
if and switch Statement counts as branch coverage , This indicator calculates the total number of branches in a method , And determine the number of branches executed and not executed .
All uncovered : All branches are not executed , Red sign
Partial coverage : Some branches are executed , Yellow sign
Full coverage : All branches have been executed , Green sign .
2.3 Methods cover
When at least one instruction in the method is executed , The method is considered to have been performed , Including constructors and static initialization methods .
2.4 Code coverage means
Analyze uncovered code , Whether the backstepping test design is sufficient , Whether there are test design blind spots in the code not covered .
2.5 Misunderstanding of coverage
If the code is as follows :
if (i>100)
j = 10/i // There is no division 0 error
else
j = 10/(i+2) // i==-2, except 0 error Cover 2 Branches , Just design i==101 and i==1, But for finding i==-2 This bug There is no effect when clicking .
therefore :
1、 Don't simply pursue high code coverage
2、 High coverage test cases do not mean that test cases are valid
3、 A branch that is not covered is equivalent to any error on the branch that cannot be found
3、 ... and 、jacoco principle
jacoco Use the method of inserting piles to record the coverage data , Through a probe Probe to inject .
The pile insertion modes are 2 Kind of :
3.1 on-the-fly Pattern
7、Jacoco Incremental coverage
7.1 Incremental coverage
Incremental coverage : What code or branches are not covered between two submissions .
Purpose : Detect the line coverage of the same test case on the code before and after modification
Suppose that the code changes submitted twice are as follows :
if(x>100)
- print(1)
+ print(2)
else
- print(3)
+ print(4)
Each line of code has 3 States :+、-、 unchanged
Before and after modification , Run the same test case , Each row has 4 States : Overwrite before modification / Not overwritten before modification , Overwrite after modification / Modified but not overwritten .
So the incremental coverage has 3x4=12 In this case , More important are : The new code does not cover , The new code covers , Unchanged code is overwritten before modification , Not covered after modification .
7.2 Incremental Application
jacoco Second opening : https://gitee.com/Dray/jacoco.git
Incremental code acquisition : https://gitee.com/Dray/dode-diff.git
Usage method :
1、jacoco client , To collect information
边栏推荐
- Ctfshow, information collection: web10
- 【目标检测】YOLOv5跑通VOC2007数据集
- Niuke real problem programming - day18
- Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
- Discussion on CPU and chiplet Technology
- MySQL installation configuration 2021 in Windows Environment
- 使用cpolar建立一个商业网站(2)
- MongoD管理数据库的方法介绍
- 【Markdown语法高级】让你的博客更精彩(四:设置字体样式以及颜色对照表)
- Integer learning
猜你喜欢
MongoD管理数据库的方法介绍
![[server data recovery] data recovery case of raid failure of a Dell server](/img/5d/03bc8dcc6e554273b34a78c49a9eaf.jpg)
[server data recovery] data recovery case of raid failure of a Dell server

拜拜了,大厂!今天我就要去厂里

使用cpolar建立一个商业网站(2)

【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码

2022年5月互联网医疗领域月度观察

【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)

什麼是數據泄露

Bye, Dachang! I'm going to the factory today

Mathematical modeling -- what is mathematical modeling
随机推荐
JSON parsing instance (QT including source code)
使用Scrapy框架爬取网页并保存到Mysql的实现
【Markdown语法高级】让你的博客更精彩(四:设置字体样式以及颜色对照表)
简述keepalived工作原理
MySQL bit类型解析
知否|两大风控最重要指标与客群好坏的关系分析
【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
TypeScript 发布 4.8 beta 版本
CTFshow,信息搜集:web3
Configure mongodb database in window environment
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
Window环境下配置Mongodb数据库
【數字IC驗證快速入門】26、SystemVerilog項目實踐之AHB-SRAMC(6)(APB協議基本要點)
Ctfshow, information collection: web8
Wechat applet 01
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
Ctfshow, information collection: web2
Change win10 Screensaver
Why do we use UTF-8 encoding?
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例