Difference between SOURCEFILE and BUNDLE elements in JaCoCo check goal

1,112 views
Skip to first unread message

Code Journal

unread,
Mar 25, 2022, 10:04:06 AM3/25/22
to JaCoCo and EclEmma Users
Hi,

The documentation for JaCoCo Maven Goal - Check seems to be very limited to provide understanding of SOURCEFILE and BUNDLE.

The way I understand these two are below.
- BUNDLE - The whole project/package coverage
- SOURCEFILE - The coverage as recorded in the executor source file

For a simple Maven project(without modules or dependent projects), both BUNDLE and SOURCEFILE can be used interchangeably, I believe.

However, I fail to understand in which cases these two will be different? Or I am completely misunderstanding this altogether?

Thanks,
Code Journal

Marc Hoffmann

unread,
Mar 25, 2022, 12:07:07 PM3/25/22
to jac...@googlegroups.com
Hi,

this specifies the granularity of the checks:

BUNDLE: The total number for all code in the module is checked
SOURCEFILE: The numbers are checked for every source file separately.

Unless the maven module has only a single source file they are indeed different.

Regards,
-marc

On 25. Mar 2022, at 15:04, Code Journal <contact.c...@gmail.com> wrote:

Hi,
--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/87c7dd26-7d71-4135-8a1e-22f8bc86cb43n%40googlegroups.com.

Code Journal

unread,
Mar 25, 2022, 12:29:10 PM3/25/22
to JaCoCo and EclEmma Users
Hi,

I still don't quite get the difference. Do you mean the following?

BUNDLE - All classes in the Maven module combined together will be checked against the rule
SOURCEFILE - Each Java file will be checked
CLASS - Each Java class file will be checked

Thanks,
Code Journal

Marc Hoffmann

unread,
Mar 25, 2022, 12:31:44 PM3/25/22
to jac...@googlegroups.com

Code Journal

unread,
Mar 25, 2022, 1:24:53 PM3/25/22
to JaCoCo and EclEmma Users
Hi,

Then how is SOURCEFILE and CLASS parameters different?

Thanks,
Code Journal

Code Journal

unread,
Mar 25, 2022, 2:24:20 PM3/25/22
to JaCoCo and EclEmma Users
Hi,

So, a little bit of research myself got my understanding clear.

SOURCEFILE will take the whole Java file as one, despite the fact that Java file might have multiple classes in them. CLASS will take each class file individually despite the fact that they can be in the same Java file.

For example, here is an example Shape.java. It defines the main Java class as Shape and there is another sub-class Triangle which extends Shape.

public abstract class Shape {
}

class Triangle extends Shape {
}


My rule configuration he as below.

<rule>
    <element>SOURCEFILE</element><!-- Here I change it for SOURCEFILE and CLASS values -->
    <limits>
        <limit>
            <counter>INSTRUCTION</counter>
            <value>TOTALCOUNT</value>
            <maximum>1</maximum>
        </limit>
    </limits>
</rule>


Below is the output for SOURCEFILE config.

[WARNING] Rule violated for source file io/codejournal/maven/jacocodemo/Shape.java: instructions total count is 6, but expected maximum is 1

When I run the same thing with CLASS config, the output is for each class separately.

[WARNING] Rule violated for class io.codejournal.maven.jacocodemo.Triangle: instructions total count is 3, but expected maximum is 1
[WARNING] Rule violated for class io.codejournal.maven.jacocodemo.Shape: instructions total count is 3, but expected maximum is 1


Got it perfectly.

Thanks,
Code Journal

Danilo Marques de Rezende

unread,
Feb 16, 2023, 8:46:58 AM2/16/23
to JaCoCo and EclEmma Users
Hi all,
I don't know if at the time of the discussion, there was an element called GROUP because it wasn't discussed here.
According to the ENUM ICoverageNode.ElementType -> https://www.eclemma.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/ICoverageNode.ElementType.html
the 'GROUP' option means 'Logical Group of Bundles'
What that means compared to the option 'BUNDLE'?

Marc Hoffmann

unread,
Feb 17, 2023, 2:57:21 AM2/17/23
to JaCoCo and EclEmma Users
Hi Danilo,

the hierarchy is:

- GROUP
    - BUNDLE
        - PACKAGE
            - CLASS/SOURCE
                - METHOD

Groups can be defined with the Ant task. Also a single (root) group is created by the Maven report-aggregate.

Regards,
-marc



Reply all
Reply to author
Forward
0 new messages