使用JUnit和Powermock覆盖Emma代码 [英] Emma code coverage with JUnit and Powermock

查看:145
本文介绍了使用JUnit和Powermock覆盖Emma代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Powermockito模拟中使用JUnit. 我必须使用maven或ant在CLI环境中工作.

I am using JUnit with Powermockito mocking. I have to work on a CLI environment with maven or ant.

emma version:      ema-2.0.5312
powermock version: powermock-mockito-1.5.1-full
junit version:     junit-4.9

当我通过以下命令运行junit时,一切正常:

When I run junit through the following command, everything works find:

java org.junit.runner.JUnitCore some.package.ClassTest

但是,当我使用emma检查代码覆盖率时:

However, when I used emma to check the code coverage:

java emmarun -cp $CLASSPATH -report txt org.junit.runner.JUnitCore some.package.ClassTest

我遇到以下错误:

1) initializationError(some.pakage.ClassTest)
   java.lang.ClassCastException: org.powermock.modules.junit4.PowerMockRunner cannot be cast to org.junit.runner.Runner

其他不使用powermock的测试类也可以正常工作. 有人对此有什么建议吗?预先感谢.

Other test classes without using powermock work fine. Does anyone have some suggestion to this? thanks in advance.

推荐答案

在使用powermock时,您无法使用Emma找出覆盖范围

while using powermock, you can not find out the coverage using Emma

在开发人员这边查看此讨论

这篇关于使用JUnit和Powermock覆盖Emma代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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