Featured image
| |

Streamlining Console Output Verification with Kotest

Console logging is often perceived as a bad practice, but in specific contexts, it’s quite suitable. Consider a scenario of a workshop where printing output directly to the console enhances transparency and simplifies the project setup. Using a comprehensive logger could lead to unnecessary clutter. However, there’s a downside to directly printing to the console—it makes it challenging to verify the result. Well, at least so I thought until I accidentally stumbled upon this awesome article by Thijs Kaper. Although Spring Boot provides out-of-the-box support for output verification, it’s also possible, and sometimes preferable, to implement it independently. In this blog post, I’ll demonstrate how to create a custom spec in Kotest that you can leverage in your tests. This spec automatically captures console output and provides the result for verification.

| |

JaCoCo beats Cobertura when it comes to Java 8 support

I’ve recently reached out for Cobertura to add test coverage reporting to one of my project. One of the first challenges I’ve face was integrating the plugin into a project powered by Gradle. Turns out there is a Gradle version of the plugin available (credit: Steve Saliman). https://gist.github.com/zezutom/8526e229a4ab01d7a69f The problem I was unable to work around when using Cobertura was…

|

Make the most of the logs when running Gradle tests

Both Maven and Gradle generate nicely formatted HTML reports. Moreover, Maven’s Surefire plugin outputs all essential information directly to the terminal. That provides an instant access to stack trace (in case of failures), logs from individual tests etc. Also, there is a nice summary at the end: [bash] ——————————————————- T E S T S ——————————————————- Running com.mycompany.app.AppTest Tests run:…

| |

JUnitParams – parameterized unit tests

Less unit test code doesn’t necessarily result into poor coverage. I’ve recently entered the paradigm of parameterized tests when refactoring a larger test suite. I ended up writing significantly less code without compromising on the extent. In fact, adding a few corner cases was almost a no-brainer. In this post I’d like to share my…