Menu

#46 Java5 enum stats incorrect

open
nobody
None
5
2005-08-16
2005-08-16
No

EMMA reports incorrect stats for the following simple enum:

public enum ProcessState{ACTIVE, COMPLETED, ABANDONED}

EMMA reports 50% method, 81% block, and 81% line
coverage. These should all be 100% since there are no
methods, blocks, or lines defined in this enum.

Discussion

  • Trejkaz

    Trejkaz - 2008-09-08

    Logged In: YES
    user_id=639492
    Originator: NO

    +1

    There is a workaround though, you can write a unit test to exercise the generated enum methods just to silence EMMA. In theory you could have a single unit test crawl your project, find all enums, load the class and run all methods.

     
  • Anonymous

    Anonymous - 2009-12-22

    If the language generates code for you, the only valid assumption is that the code generation has been tested already. I understand that the Sun JVM marks all the auto-generated code at line "1" for enums. The correct approach would then be to ignore this autogenerated code.

     

Log in to post a comment.