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.

Busy busy busy

I’ve been really busy with evaluating student coursework in two courses. Some of this work was postponed in Feb/March since I participated in the international MSc program selection process then.

I have been considering posting shorter news like things or just small snippets of work I have been doing. Just to keep this blog alive.

So here is a screenshot of something I did in between the course evaluations — potentially a new exercise to be used in the Data structures and algorithms course next Fall. A small utility that converts plain Finnish text to braille symbols.

Finnish epic Kalevala in braille.

The job for the students is to generate the braille version faster than the naive lookup table looping implementation they get ready, using hash tables.

Another thing I did was for a course on GUI design & programming:

Demo about automated GUI testing

The purpose of this stupid card guessing game was to demonstrate how to implement a simple GUI test automation and execute the tests in simulator environment.

That’s it for today. Now back to evaluating those student programming assingments…