Thank you for your answer!

But I am confused with a problem: We can get the probs information(in executing 
data)
and the class file. So if I write something to find where is the probs in the 
class file,
would I get the information that I want?

For example, here is the code:

public int greaterThen(int intOne, int intTwo) {
    if (intOne > intTwo) {
        return 0;
    } else {
        return 1;
    }
}

And when it comes to bytecode:

0: iload_1
1: iload_2
2: if_icmple     7
5: iconst_0
6: ireturn
7: iconst_1
8: ireturn

If JaCoCo insert the prob between the 5 and 6 , for example prob[5] in the 
executing data

Without considering  the efficiency, can I finally check the class file and 
find the prob[5] is 
between the 5 and 6, then backstepping to find that the java code execute 
“return 0” 
and we miss the branch“intOne<=intTwo” ?

Just an idea, and hope for your reply.

Thank you!



发件人: Marc Hoffmann
发送时间: 2017年11月14日 19:46
收件人: [email protected]
主题: Re: [java code coverage] Can we know the details about the branchcoverage 
by JaCoCo?

Hi,

short answer: JaCoCo does not provide this information.

JaCoCo is fully based on Java class files (bytecode). The only mapping 
back to source are the line numbers contained with the debug 
information. Within a line we cannot differentiate what exactly has been 
executed.

In OpenJDK there is a experimental flag which provides more fine-grain 
mapping. We created a POC using this extra information:

   https://github.com/jacoco/jacoco/pull/317

As a workaround you might break complex conditions in multiple lines.

Regards,
-marc


On 2017-11-14 09:19, [email protected] wrote:
> Hello.
> 
> I found that if a branch was missed, only a yellow bolck was be shown
> and said "1 of 2 branches missed." or other words like this.
> 
> However, could we know some details about it? Such as "1 of 4 branches
> missed. True/False/True/True"?
> 
> In other words, is there any possiblity to konw which side of the
> branch have been executed?
> 
> Thanks!

-- 
You received this message because you are subscribed to a topic in the Google 
Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/jacoco/h0VJYpAeb9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/7056b1568c1f62336375458442a4b5b6%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/5a0c109f.83c4620a.6903b.9121%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to