Welcome to another issue of my newsletter!
In the previous special newsletter edition, we covered the Log4Shell vulnerability that caused a lot of trouble in the IT world, and it even continued with some more trouble and more discovered vulnerabilities since then. I’ve updated my blog post with some updated versions. So, if you checked and updated your Log4j 2 version, you should check again. Someone on Twitter wrote that it’s “Funny how people keep saying Java is dying until you have to find out by force it runs virtually everywhere” (paraphrased, I don’t remember the exact words). I couldn’t help but smirk at that tweet :-)
However, let’s cover some different topics in this episode.
99 bottles of beer — coding session
I got some comments on my YouTube videos that it would be helpful and inspiring to watch me coding a longer programming task, to see what approaches, tools, and shortcuts I’m using. I found that a nice idea and so I recorded a coding session programming the well-known “99 bottles of beer” song in Java:
For that exercise, one should write a Java method that emits the following song as array, with each line as array element:
99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall. 98 bottles of beer on the wall, 98 bottles of beer. Take one down and pass it around, 97 bottles of beer on the wall. [...] 2 bottles of beer on the wall, 2 bottles of beer. Take one down and pass it around, 1 bottle of beer on the wall. 1 bottle of beer on the wall, 1 bottle of beer. Take one down and pass it around, no more bottles of beer on the wall. No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall.
In this video you can watch me solving that task.
Using JaCoCo to measure system test coverage
You likely now that I’m a big fan of the topic of enterprise testing. Measuring the test coverage of your code can quickly become a heated topic, especially with regards to which percentage is the right number.
I’ve recorded a video in which I’m showing a slightly different approach to code coverage, one that uses system tests with the application’s endpoints, in order to see how well our test scenarios cover all use cases. For that, I will use JaCoCo and its JVM agent to gather the data while our application-under-test is running as usual.
We attach the JaCoCo JVM agent to our application as follows:
java \ -javaagent:/.../org.jacoco.agent-0.8.7-runtime.jar \ -jar target/quarkus-app/quarkus-run.jar
That will produce a
jacoco.exec file in the working directory, which we can examine after the application has stopped.
When we fire our system tests against that application, the actual code coverage caused by our test suite will be recorded.
Have a look at the video for more details and how to further use this
Thanks a lot for reading and see you next time!
Did you like the content? You can subscribe to the newsletter for free: