如何开始编写代码覆盖率工具? [英] How to get started writing a code coverage tool?

查看:107
本文介绍了如何开始编写代码覆盖率工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找实际上讨论如何来编写Java代码覆盖工具的书籍或其他参考资料;各种技术或技巧中的一些-源代码与字节代码检测。

Looking for books or other references that discuss actually how to write a code coverage tool in Java; some of the various techniques or tricks - source vs. byte code instrumentation.

这是一种用于在后台生成Java字节代码的脚本语言。

This is for a scripting language that generates Java byte code under the hood.

推荐答案

您的脚本语言是否生成字节码?它会生成调试元数据吗?如果是这样,字节码检测可能是解决之道。实际上,现有工具可能会起作用(也许只需进行少量修改即可。)。

Does your scripting language generate bytecode? Does it generate debug metadata? If so, bytecode instrumentation is probably the way to go. In fact existing tools will probably work (perhaps with minimal modification).

此类工具的典型问题是,它们被编写为可与Java一起使用并假定 class com.foo.Bar.class 对应于文件 com / foo / Bar.java 。取消该假设可能很乏味。

The typical problem with such tools that they are written to work with Java and assume that a class com.foo.Bar.class corresponds to a file com/foo/Bar.java. Unwinding that assumption can be tedious.

EMMA 是一个ClassLoader,它为Java中的代码覆盖收集执行字节代码重写。编码风格有些时髦,但是我建议阅读源代码以获取一些想法。

EMMA is a ClassLoader that does byte-code re-writing for code-coverage collection in Java. The coding style is a little funky, but I recommend reading source code for some ideas.

如果您的脚本语言得到了解释,那么您将需要一个更高级别的类加载器(在源代码级别)连接到解释器。

If your scripting language is interpreted then you will need a higher-level class loader (at a source level) that hooks into the interpreter.

这篇关于如何开始编写代码覆盖率工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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