Hi, JaCoCo is based on bytecode. Internally it calculates the execution status and branched of every bytecode instruction (using execution data file together with the original class files). So JaCoCo does not evaluate the data (like condition1 and condition2 in your example). It simply looks at the control flow graph of the bytecode.
For example in your case you’re using the logical shortcut operator &&. Which means when condition1 == false then condition2 is not evaluated at all. So the cases FT and FF cannot be distinguished. Some pointers for for further research. Here is the description how we analyze the control flow of bytecode: https://www.jacoco.org/jacoco/trunk/doc/flow.html <https://www.jacoco.org/jacoco/trunk/doc/flow.html> As said above internally we calculate the execution status of every instruction and aggregate it on method/line level. There is (currently) no API to get coverage information of single instructions. But you might take a look at our code and experiment with a fork: https://github.com/jacoco/jacoco/blob/master/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java#L73 <https://github.com/jacoco/jacoco/blob/master/org.jacoco.core/src/org/jacoco/core/internal/analysis/MethodCoverageCalculator.java#L73> Regards, -marc > On 9. Sep 2019, at 18:19, insomnia Lee <[email protected]> wrote: > > > Hello, those days, I have tried to develpoe a tool based on JaCoCo, I just > want to get more information about branch coverage of java bytecode, I don't > care which branch have been passed and which not. What I want to konw is that > in a condtion like if(condition1&&condition2) , It's not necessary that if > condition1 = true and condition2 = flase pass or not, But I want to know, in > the four branch ( TT TF FT FF ) corresponding to ( A B C D ), We have > four orderd condtion( a b c d ) which is not one-to-one with (ABCD), Their > order is determined according to the analysis program. I want to know that > if condition (a) have been passed or not. Can I analyze the probe array to > get the branch coverage information? I am not sure about it. If you have an > idea about how to do it, I will be very grateful, I am looking forward to > your early reply, Thank you very much!!! > > -- > 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] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/b2eb1969-7505-4e1d-9e0b-7d5607d52648%40googlegroups.com > > <https://groups.google.com/d/msgid/jacoco/b2eb1969-7505-4e1d-9e0b-7d5607d52648%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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/B1B66324-E85B-4EF6-AB7A-C5401412BCFA%40mountainminds.com.
