Why does Cobertura report 0% coverage when run through the Eclipse plugin?

狂风中的少年 提交于 2019-12-22 08:43:57

问题


(There are a tonne of these questions, but all the ones I can find relate to Maven. Before you suggest this one is a duplicate, please understand that this doesn't relate to Maven in any way.)

I am using Cobertura within Eclipse to determine my percentage of code covered by my JUnit tests. All 99 of my unit tests run successfully, both within and outside of Cobertura, but Cobertura reports back that they have covered 0% of my code.

I :

  • am running Cobertura through the Eclipse plugin
  • am using Java 6, specifically OpenJDK-AMD64 on Ubuntu
  • have ensured that the unit tests do cover some sections of my code
  • have ensured that Cobertura is running all my test folder on all of my src folder
  • have tried to clean and rebuild

Why does Cobertura report 0%?


回答1:


I found that this was a problem for me because I was compiling my source files without line numbers. If this is your problem, you will see

[cobertura-instrument] WARN visitEnd, No line number information found for class com.x.y.z.A.
Perhaps you need to compile with debug=true?

To solve this, add debug="true" debuglevel="vars,lines,source" to your javac command.

See also:

http://meera-subbarao.blogspot.co.uk/2008/07/cobertura-instrument-warn-visitend-no.html

How to remove specific Cobertura warning?



来源:https://stackoverflow.com/questions/19098937/why-does-cobertura-report-0-coverage-when-run-through-the-eclipse-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!