方法的检测线

发布于 2025-01-06 07:41:02 字数 499 浏览 0 评论 0 原文

我需要以编程方式检测方法的代码行,以便我可以知道某个执行触及或未触及哪些行 - 我想要在行号和它们是否运行之间有一个映射。

到目前为止,我一直在使用 JaCoCo 来执行此检测。但是 JaCoCo 检测了整个类,我想控制检测哪些方法。

我可以使用 ASMBCELjavassist?如果是这样,有人可以给我指出一些文档或教程吗?

I need to programmatically instrument the lines of code of a method so that I can know what lines were touched or not by a certain execution - I want to have a map between the line numbers and if they were run or not.

So far, I have been using JaCoCo to perform this instrumentation. But JaCoCo instruments the whole class and I want to have control of what methods are instrumented.

Can I do this with libraries like ASM, BCEL or javassist? If so, can anyone point me to some documentation or tutorial?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花间憩 2025-01-13 07:41:02

您可以查看 Cobertura 源代码 (它本身使用

You can look at Cobertura source code (that itself uses ASM). It is not a tutorial, but on the other hand, it is a real world example, and not a toy.

天涯离梦残月幽梦 2025-01-13 07:41:02

有许多代码覆盖率工具,许多都具有 IDE 集成,因此您可以通过运行程序轻松生成这些报告。您还可以使用 Maven 生成报告。

最简单的解决方案是找到一个开源代码覆盖工具,它可以完成您想要的功能并对其进行增强,也许该工具的开发人员会接受您的改进。

以下列出了十三个与封面报道相关的工具,可帮助您入门。
http://www.java-sources.com/open-source/code-coverage

There are many code coverage tools, many have IDE integration so you can easily generate these reports by running the program. You can also use maven to generate the reports.

The simplest solution is to find an open source code coverage tool which does what you want and enhance it and perhaps the developers of the tool will take your improvements.

Here is a list of thirteen cover coverage related tools to get you started.
http://www.java-sources.com/open-source/code-coverage

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文