Can fully covered code have an EclEmma coverage rating of less than 100%?

最后都变了- 提交于 2019-12-01 17:55:01

Your code implies a default constructor, which can't be properly tagged by Emma, because it doesn't have a block of text.

Since it is not properly tagged within the block of text, Emma can't associate the coverage logging with the text file, and it looks like some code isn't covered; because, you ran some bytecode, but the line logging couldn't be registered. Later when the reporting element reads the line logging, they can't find the line numbers for the default constructor, and it highlights the error in the only place that sort of makes sense, the class declaration line.

The default constructor looks like

public Arithmetic() {
  super();
}

Where the super is the implied first instruction which will construct Object. While you may omit its presence, the compiler will add it in for you. That's where your get "3 lines" instead of one.

I think you will either need to test the instantiation of Arithmetic as well, or declare its constructor private to disallow instantiation

IIRC, you need to instantiate an instance of the class to exercise the language provided constructor.

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