Cobertura如何与JUnit合作? [英] How does Cobertura work with JUnit?

查看:309
本文介绍了Cobertura如何与JUnit合作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法理解Cobertura如何与JUnit合作。据我所知,cobertura修改了编译的字节代码,并在此字节代码中插入了自己的命令。好。之后我们运行Junit框架并将其运行测试。任何人都可以解释cobertura在什么点上获取其命令执行的信息?

I can't understand how Cobertura cooperates with JUnit. As I understood cobertura modifies compiled byte code and inserts in this byte code its own commands. Ok. After that we run Junit framework and give it our tests to run. Could anyone explain at what points cobertura gets the information which of its commands were executed?

推荐答案

Cobertura使用 ASM ,这是一个通用的字节码操作和分析框架。在每行java代码中,有3行添加到现有类中,以计算它生成的报告的内容。当Cobertura包含在您的类路径中并正确配置并执行单元测试时,它将生成一个名为cobertura.ser的数据文件,用于生成xml或html报告。

Cobertura uses ASM which is a general purpose bytecode manipulation and analysis framework. On every line of java code there are 3 lines added to the existing classes to count things for the report it produces. When Cobertura is included in your classpath and configured correctly and you execute your unit tests, it will produce a datafile called cobertura.ser which is used to produce an xml or html report.

基本用法:使用Maven: http://www.mojohaus.org/cobertura-maven-plugin/ usage.html

Basic usage: with Maven: http://www.mojohaus.org/cobertura-maven-plugin/usage.html

这篇关于Cobertura如何与JUnit合作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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