java - Maven Cobertura plugin generating incomplete coverage report -


i'm using:

mvn cobertura:cobertura 

to generate coverage report project. isn't configured in pom.xml file, it's using latest version of plugin (currently 2.6).

for part works ok, reason 1 class has odd report. seems reporting lines have been covered, other lines (which right next it) not.

i've been running:

mvn clean 

of course, doesn't seem help.

overall it's reporting 1% coverage, quite key class know getting used lot. know reports used work ok. i'm not sure when stopped working, i've not inspected class's coverage while.

as example of i'm seeing:

2053 private final list<entityproperty<t>> properties = new arraylist<entityproperty<t>>();           private final propertydescriptor idproperty; 0    private final set<string> fieldorder = new linkedhashset<string>(); 0    private final map<string, string> additionalfieldlabels = new hashmap<string, string>(); 

this initialiser of class. first line apparently gets called 2053 time. 2nd line doesn't run code, left blank (as indicated), 3rd , 4th lines both report being called 0 times.

another example:

2053 public entityintrospector(adminapp app, entityapplication entityapp, class<t> entityclass) { 0        this.app = app; 

from constructor itself. again first line called 2053 times, 2nd (and other lines in constructor) called 0 times.

anyway i'm @ loss why happening.

i suspect maybe it's library somehow interfering coverage/instrumentation somehow.

possibly class size factor. source file pretty weighty 2040 lines long (918 actual lines of code count towards coverage).

i've been writing other tests , code on last few days , cobertura working fine those.

hints , suggestions welcome.

so seem seem class large. hacked @ class in question comment out lines. made whole load of tests fail, coverage seems working again.

the class 804 lines long (in terms of lines can covered).

so looks there sort of effective limit on how large class cobertura can handle.

in case means class refactoring break code bit.

update (3rd june 2015): refactored class in question down 790 lines , still had same problem. in end issue seemed related code in constructor. had like:

try {     final beaninfo beaninfo = introspector.getbeaninfo(entityclass);     // rest of constructor here (about 50 lines) } catch( introspectionexception ie ) {     throw new runtimeexception(ie); } 

i changed have method like:

protected beaninfo getbeaninfo(class<t> entityclass) {     try {         return introspector.getbeaninfo(entityclass);     }     catch( introspectionexception ie ) {         throw new runtimeexception(ie);     } } 

which instead called within constructor. way know longer needed try/catch inside constructor itself.

i'm not 100% sure if fixed issue making constructor shorter in length or if moving try/catch made difference.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -