这三种代码覆盖率分析方法有什么区别? [英] What are the differences between the three methods of code coverage analysis?

查看:694
本文介绍了这三种代码覆盖率分析方法有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此声纳页面基本列出了各种方法由不同的代码覆盖率分析工具使用:

This sonar page basically lists the various methods employed by different code coverage analysis tools:


  1. 源代码检测(由Clover

  2. 离线字节码检测(由Cobertura

  3. 动态字节码检测(由 Jacoco )

  1. Source code instrumentation(Used by Clover)
  2. Offline byte code instrumentation(Used by Cobertura)
  3. On-the-fly byte code instrumentation(Used by Jacoco)

这三个是什么方法,哪一个是最有效的,为什么?如果效率问题的答案是它取决于,那么请解释原因?

What are these three methods and which one is the most efficient and why?If the answer to the question of efficiency is "it depends" , then please explain why?

推荐答案

源代码检测包括在编译之前向源代码添加指令。这些指令用于跟踪代码的哪些部分已被执行。

Source code instrumentation consists in adding instructions to the source code before compiling it. These instructions are used to trace which parts of the codes have been executed.

离线字节码检测包括添加相同的指令,但在编译之后,直接进入字节码。

Offline byte-code instrumentation consists in adding those same instructions, but after the compilation, directly into the byte-code.

动态字节码检测包括在字节码中添加相同的指令,但在运行时动态地在字节码中添加代码由JVM加载。

On-the-fly byte-code instrumentation consists in adding those same instructions in the byte-code, but dynamically, at runtime, when the byte-code is loaded by the JVM.

此页面对方法进行了比较。它可能有偏见,因为它是Clover文档的一部分。

This page has a comparison between the methods. It might be biased, since it's part of the Clover documentation.

根据您对有效的定义,选择您最喜欢的那个。我不认为你会得到巨大的差异。他们都做了这个工作,无论使用哪种方法,大局都是一样的。

Depending on your definition of "efficient", choose the one you like the most. I don't think you'll get enormous differences. They all do the job, and the big picture will be the same whatever the method used.

这篇关于这三种代码覆盖率分析方法有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆