Aaah, perfect! I oversaw the offset field in sourceFiles part! (and was confused, that the number of lines doesn't match the number of source lines... ) For the "ease of use", I guess the XML will be the preferred way.
Thanks a lot for the help!! Have a nice weekend! Nikola On Fri, Aug 14, 2020 at 3:52 PM Marc Hoffmann <hoffm...@mountainminds.com> wrote: > Aha, in this case you can also use the JaCoCo XML report which provides > line by line coverage data. See for example: > https://www.jacoco.org/jacoco/trunk/coverage/jacoco.xml > > It is basically the same structure as the API. > > If you want to related it to git change sets I I would recommend to > Navigate BundleCoverage —> Packages —> SourceFiles —> Lines. Methods can be > tricky as they can overlap (e.g. in case of anonymous inner classes, > lambdas) and a single source file can result in many classes. > > Regards, > -marc > > On 14. Aug 2020, at 15:26, Nikola Veber <nikola.ve...@gmail.com> wrote: > > Hi Marc, > > thanks for bringing me back to that example! > > In essence, I want to combine git blame with code coverage, in order to > figure out how much "new code" is untested. > A crude way would be parsing the HTML report, but I was hoping to find a > more elegant solution. > For that, I need to align the source-code lines with the coverage data. I > failed last time, but today I got a step further by examining the example > more closely. > > What I still need to figure out: > In BundleCoverage -> Packages -> Classes -> lines, there is an array of > coverage information for what seems to correspond to course lines. > > Also interesting are BundleCoverage -> Packages -> Classes -> methods. > The offset field of each method seems to denote the line number of the > first line of method code. Some lines are null, which I assume are the > whitespaces. > > Would it be safe to assume that the "lines" array in the method represents > all source lines after the start of the method (=offset)? > Basically, is the assumption that offset + lines[i] == source line number? > > > Thanks! > Nikola > > > On Fri, Aug 14, 2020 at 12:09 PM Marc Hoffmann <hoffm...@mountainminds.com> > wrote: > >> Hi Nikola, >> >> not sure what yoe exactly want to do. But if you want to get line-by-line >> coverage information JaCoCo provides the interface ISourceNode >> <https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/ISourceNode.html> >> . >> >> This ReportGenerator Example >> <https://www.jacoco.org/jacoco/trunk/doc/api.html> shows how to generate >> the JaCoCo coverage model. >> >> Regards, >> -marc >> >> >> On 14. Aug 2020, at 11:59, Nikola Veber <nikola.ve...@gmail.com> wrote: >> >> Hi Marc, >> >> thanks for the quick reply! >> >> I am aware of the process (class files + source files + exec = line-level >> coverage report). My attempt was to tweak the html report generator to give >> me the data I need, but was unable to understand how to connect the dots.. >> Do you have any pointers for me, where to find the specific code which >> does the correlation between inserted probes and the source code? (as this >> needs to happen somehow, in order to generate the report...) >> >> >> Best regards, >> Nikola >> >> >> >> >> On Fri, Aug 14, 2020 at 11:43 AM Marc Hoffmann < >> hoffm...@mountainminds.com> wrote: >> >>> Hi Nikola, >>> >>> there is no simple relationship between probes and line numbers. Probes >>> are inserted based on the control flow in methods. Line numbers depend on >>> your source code formatting and the compiler. >>> >>> That’s why JaCoCo needs the original class files to reconstruct coverage >>> data from probes. The algorithm is documented here: >>> https://www.jacoco.org/jacoco/trunk/doc/flow.html >>> >>> So my recommendation is to use JaCoCo based tools or the JaCoCo Java API >>> to create line coverage. Here are some code examples: >>> https://www.jacoco.org/jacoco/trunk/doc/api.html >>> >>> Regards, >>> -marc >>> >>> >>> >>> On 14. Aug 2020, at 10:01, Nikola Veber <nikola.ve...@gmail.com> wrote: >>> >>> Hi, >>> >>> I have tried to figure this out by debugging during report generation, >>> but without much luck. >>> >>> Can you suggest a way to get a correlation between source line numbers >>> and probe "ids"? >>> >>> I would like to have something like >>> line x -> depends on probes [0, 2, 7] >>> (or the other way around) >>> >>> >>> Cheers, >>> Nikola >>> >>> -- >>> 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 jacoco+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jacoco/0e5fc174-1e86-4f1b-a70e-2670506baa9bn%40googlegroups.com >>> <https://groups.google.com/d/msgid/jacoco/0e5fc174-1e86-4f1b-a70e-2670506baa9bn%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> >>> >>> -- >>> 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/Gf8B6MwehNo/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> jacoco+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jacoco/5FF45787-D124-4D49-AF30-A25A8F58AEE1%40mountainminds.com >>> <https://groups.google.com/d/msgid/jacoco/5FF45787-D124-4D49-AF30-A25A8F58AEE1%40mountainminds.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 jacoco+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jacoco/CA%2BrO3sXU6o9a_hfFWdLSw-2YUWGQsGe4%3D%3D-ttD1ZonCroSDRuA%40mail.gmail.com >> <https://groups.google.com/d/msgid/jacoco/CA%2BrO3sXU6o9a_hfFWdLSw-2YUWGQsGe4%3D%3D-ttD1ZonCroSDRuA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> >> >> -- >> 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/Gf8B6MwehNo/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> jacoco+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jacoco/E820F50F-4845-4782-9EC9-B14E7214308E%40mountainminds.com >> <https://groups.google.com/d/msgid/jacoco/E820F50F-4845-4782-9EC9-B14E7214308E%40mountainminds.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 jacoco+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/CA%2BrO3sUkxzXSfN%3DGMjtewMc2tLk-5F9DD13%3DP5iMUYHoPq%3D7HQ%40mail.gmail.com > <https://groups.google.com/d/msgid/jacoco/CA%2BrO3sUkxzXSfN%3DGMjtewMc2tLk-5F9DD13%3DP5iMUYHoPq%3D7HQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > > -- > 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/Gf8B6MwehNo/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > jacoco+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/2348CB60-F2F8-41D0-9B1C-69365CD97DEC%40mountainminds.com > <https://groups.google.com/d/msgid/jacoco/2348CB60-F2F8-41D0-9B1C-69365CD97DEC%40mountainminds.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 jacoco+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CA%2BrO3sWEnjU3b089MUYbAt5eKmkvfNbD0%3D2aG18LtLZV62yAzQ%40mail.gmail.com.