6

I'm using Eclipse-STS + EclEmma plugin to see coverage of my code. In all my abstract util classes (with only static methods) I see 3 missed instructions (Instructions Counter report) at the class definition line:

enter image description here

No marker available at the left of the red line, so I do not know exactly what are these instructions. Maybe some constructors? What can I do to cover them?

madhead
  • 31,729
  • 16
  • 153
  • 201
  • 1
    I don't know the answer to this question, but I am curious as to why this is so important to you. Are you required to get 100% coverage? IMO, coverage tools like Emma are best at signifying weak spots in your testing. If you know these instructions are covered, but emma doesn't show it, that is not a problem with your tests (although it may indicate a bug in emma). – Andrew Eisenberg Feb 11 '13 at 04:03
  • 4
    I'm just a perfectionist and want to see that cherished number in reports. Also, I'm just curious. – madhead Feb 11 '13 at 06:12
  • 1
    I get it. :-) Wish I had an answer for you. – Andrew Eisenberg Feb 11 '13 at 20:26

1 Answers1

3

One way I found to achieve 100% covering is to write a test method like this:

@Test
public void coverage(){
    KeyEscaper a = new KeyEscaper() {
    };
}

As soon as the issue touches only utils classes with all static methods, it's not a problem to instantiate them anonimously in such way.

madhead
  • 31,729
  • 16
  • 153
  • 201
  • Just doing a `new KeyEscaper();` should be enough. Also, you could put it in a static method with `@BeforClass` so you don't have to create a dummy test. – seeker Jul 05 '13 at 10:09
  • Cannot do `new`, as the class is abstract. – madhead Jul 05 '13 at 12:28
  • 1
    You can combine the two approaches though (anonymous subclass, but without local variable) by simply `new KeyEscaper() {};`. – Joshua Taylor Jul 10 '13 at 13:15