Uncategorized

Don’t mock static: test SLF4J Logger with appenders

Most of the time you would like to inject dependencies to your class directly – through the class constructor or by setting required properties via setters. No matter what programming style you prefer you may encounter situation when some dependency cannot or shouldn’t be passed directly to your system under test. Good example of that …

Don’t mock static: test SLF4J Logger with appenders Read More »

Building assertions with Strikt

Strikt is assertion library built for Kotlin with API that allows building fluent assetions. To add library to project, add following dependency to your build.gradle repositories { mavenCentral()}dependencies { testImplementation("io.strikt:strikt-core:0.31.0")} To get latest version, visit Github Releases page: https://github.com/robfletcher/strikt/releases Basic usage Good assertion library should give us readable assertion errors. Strikt renders error in the …

Building assertions with Strikt Read More »

Fighting Testing Boilerplate with IntelliJ IDEA Live Templates

This article will focus on JUnit 5, but most of the things should be applicable for any other testing framework, your imagination is the only limit. JUnit5 File and code templates IntelliJ IDEA allows creating test classes with the following shortcut (Ctrl + Shift + T / ⇧ + ⌘ + T). This window allows …

Fighting Testing Boilerplate with IntelliJ IDEA Live Templates Read More »

IntelliJ Live Template that makes my life little easier

Creating unit test usually requires some boilerplate – you have to create separate class in proper directory, add annotations and provide test method name. While it’s not much, I started to think: how can this boilerplate could be reduced? To make our test discoverable by test framework and IDE, we usually need to annotate test …

IntelliJ Live Template that makes my life little easier Read More »

Why my date formatters test fails in CI and passes locally?

The issue For new Android project I decided to go with Github Actions as CI environment – we use Github across organization and some backend projects are already running in Github workflows, creating new project with is a good idea. I’ve prepared configuration using following tutorial: How-to Github Actions: Building your Android App I’ve recently …

Why my date formatters test fails in CI and passes locally? Read More »

Introducing stories: Quick Testing Tips

Available for web and mobile at: https://stories.kotlintesting.com I will share stories on social media, and after first release cycle I will write up summary for tips and tricks that weren’t mentioned in blog posts before. Make sure to follow KotlinTesting social media profiles on Facebook and Twitter: KotlinTesting KotlinTesting. Mi piace: 29. Helping people write …

Introducing stories: Quick Testing Tips Read More »