From: <dun...@bt...> - 2010-04-23 16:23:23
|
...so you have to instantiate the class, even though it was never designed for that. Try adding "private JPAHelper dummy=new JPAHelper();" Duncan. ________________________________ From: Jake Cobb [mailto:jak...@ga...] Sent: 23 April 2010 17:13 To: Alan Chaney Cc: cob...@li... Subject: Re: [Cobertura-devel] report shows class statement as red on simplestatic class Alan, You're seeing the default constructor (equivalent to public JPAHelper() {}) that is automatically generated when no constructors exist in the source. Cobertura operates on the byte-code and when a default constructor is generated this way it maps to the class declaration in the source. -Jake On Fri, Apr 23, 2010 at 11:58 AM, Alan Chaney <al...@me...> wrote: Hi I'm new to cobertura, but increasingly impressed with how useful having an understanding of coverage can be. I'm spending some time trying to understand some odd cases in my coverage reports where I think I should have tested everything but I'm still getting some indications that coverage is not 100% complete. My question concerns a simple static class that I have. I've written some Junit tests for it, and the report shows 100% branch coverage, but the line coverage shows 7/8 because the class statement line appears in red. I can't think of any test that I can write that would exercise this becauset the class has only one method (as below.) Why is it failing? What should I do to make it green? Does it matter? and is there anywhere I find more information about how the coverage report is generated (apart from reading the source, of course!) I've read all the referenced articles on the FAQ and Googled for Thanks in advance Alan package com.mycompany.project import java.lang.reflect.Field; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import javax.persistence.OneToOne; public class JPAHelper { <<=== THIS LINE APPEARS IN RED, everything else is green or gray /** * The parent of the field should be an @Entity. It should have either a OneToOne, * ManyToOne, or ManyToMany annotation * @param f * @return The implementation class */ public static Class<?> findImplementationClass(Field f) { if (f.isAnnotationPresent(OneToMany.class)) { return f.getAnnotation(OneToMany.class).targetEntity(); } else if (f.isAnnotationPresent(ManyToMany.class)) { return f.getAnnotation(ManyToMany.class).targetEntity(); } else if (f.isAnnotationPresent(OneToOne.class)) { return f.getAnnotation(OneToOne.class).targetEntity(); } return null; } } ------------------------------------------------------------------------ ------ _______________________________________________ Cobertura-devel mailing list Cob...@li... https://lists.sourceforge.net/lists/listinfo/cobertura-devel |