In the coverage result, it shows that I've covered 9 instructions while there are only 5 lines highlighted green. Which are the other 4 instructions?
Asked
Active
Viewed 807 times
3
-
1Maybe it means bytecode instructions. – shmosel May 03 '16 at 16:30
-
@shmosel : I don't think that's the case – Akash Agarwal May 03 '16 at 16:31
2 Answers
5
Click the dropdown arrow at the top right of the Coverage box. It'll give you a couple different ways to measure your coverage. The default seems to be instructions (bytecode instructions), but you can manually select lines.
The reason you are seeing 9 instructions is because there are 9 bytecode instructions in Foo
:
$ javap -c Foo.class
Compiled from "Foo.java"
public class Foo {
public Foo();
Code:
0: aload_0
1: invokespecial #8 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #22 // String Test
5: invokevirtual #24 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: new #1 // class Foo
11: invokespecial #30 // Method "<init>":()V
14: return
}

Jeffrey
- 44,417
- 8
- 90
- 141
2
As @schmosel says, it is counting bytecode instructions.
You can verify this by reading the EMMA reference documentation (EclEMMA is an Eclipse GUI wrapped around EMMA), in which the phrase "bytecode instructions" is used throughout.

slim
- 40,215
- 13
- 94
- 127
-
Can you please refer me to a link where I can find the bytecode instructions EcLemma is running? – Akash Agarwal May 03 '16 at 16:40
-
The most general solution is javap https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javap.html -- you may seek out your own GUI equivalent if you like. – slim May 03 '16 at 16:42
-
So which class should I run with the javap command for my query, if you may know? – Akash Agarwal May 03 '16 at 16:43