Coverage fight

Well it was a fight but got the code coverage working with VS Code / Java and Coverage Gutters extension. Doing this for an exercise under preparation for the next Fall course on Data Structures and Algorithms. Probably this is just a demo or something students may take a look at, not a required task.

Code coverage visible, YEAH!!

What I have in the Maven pom.xml currently is

<argLine>-Xmx2048m</argLine>

within the properties struct, and in the build/plugins:

<plugin>
   <artifactId>maven-failsafe-plugin</artifactId>  
   <version>2.22.2</version>
      <configuration>
        <argLine>${argLine} -Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
      </configuration>
</plugin>

and the whole jacoco plugin structure is here, under the build/plugins structure (with some commented out sections):

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.8</version>
    <executions>
        <execution>
            <id>pre-unit-test</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
            <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                <propertyName>surefireArgLine</propertyName>
            </configuration>
        </execution>
        <!-- Ensures that the code coverage report for unit tests is created 
              after unit tests have been run. -->
        <execution>
            <id>post-unit-test</id>
            <phase>test</phase>
            <goals>
                <goal>report</goal>
            </goals>
            <configuration>
                <!-- Sets the path to the file which contains the execution data. -->
                <dataFile>${sonar.jacoco.reportPath}</dataFile>
                <!-- Sets the output directory for the code coverage report. -->
                <outputDirectory>${jacoco.path}</outputDirectory>
            </configuration>
        </execution>
        <execution>
            <id>default-report</id>
            <goals></goals>
            <configuration>
                <dataFile>${project.build.directory}/jacoco.xml</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
            </configuration>
        </execution>
        <execution>
            <id>jacoco-check</id>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
                <rules>
                    <rule>
                        <element>PACKAGE</element>
                        <limits>
                            <limit>
                                <counter>LINE</counter>
                                <value>COVEREDRATIO</value>
                                <minimum>0.0</minimum>
                            </limit>
                        </limits>
                    </rule>
                </rules>
            </configuration>
        </execution>
    </executions>
</plugin>

and finally, you need to build from the command line with this Maven command:

mvn jacoco:prepare-agent package jacoco:report

So when viewing the code then, you can see the code coverage colors in the code editor sidebar on the left.