Red Dead Redemption 2

I’ve been a gamer for a very long time – it’s easily been twenty years or more (yes, I’m old). But, in the past year or so, my excitement has been waning. I have mentioned in another blog post that I was planning to replace my big tower PC with a notebook for (mobile) coding and writing – which I have done – and, in the short- to mid-term, get a gaming console to replace the video gaming part of the PC with something more casual and affordable. This day has finally come and the first game I have played has been Red Dead Redemption 2. Now, this game was many firsts for me:

  • First non-digital game since Steam has launched. I bought it in a retail store on a BluRay disc.
  • First full-price video game at 60€. Before that, I have always been shopping for special offers and discounts.
  • First console game.

I think Red Dead Redemption is something very special and I will try to explain why I think that is. One thing is for sure and that is the fact that it has rekindled the fire within me to play a video game on-end without pause. Unlike the other game reviews/experience reports I have written so far, this one is a bit different. I started writing when I was about 40% through the game and added to it at different stages of progress. In short: it’s like a diary.

Read More »

Unwanted JUnit 4 Dependency with Kotlin and JUnit 5

I ran across this issue only by accident because I was investigating a completely different problem. I wrote a quick test to debug my issue and was wondering why custom serializers and deserializers are not registered with the Jackson ObjectMapper. I had a nice init() function that was annotated with @Before. So, what the hell?

Let’s back up a bit for some context.

  • Kotlin Project
  • Runs on Java 12
  • JUnit 5 as test engine
  • AssertK for assertions (just for the sake of completeness)

I’m used to JUnit 4, so in my test I used @Before to annotate a setup method. It was one of the many options IntelliJ presented to me.

@Before
fun init() {
    val module = SimpleModule()
    module.addDeserializer(Instant::class.java, InstantDeserializer())
    module.addSerializer(Instant::class.java, InstantSerializer())
    mapper.registerModule(module)
}

The method wasn’t called, however. But it’s annotated! Well, it’s the wrong annotation if you’re using JUnit 5. The correct one is @BeforeEach. This one and @BeforeClass (new name @BeforeAll) have been changed from version 4 to 5 to make their meaning more obvious.

But that’s besides the point. The question is: where does this @Before come from then?

A look at the dependency tree quickly reveals the culprit.

It’s the official JetBrains Kotlin JUnit test artifact. Although it doesn’t hurt me to have it in my project, it certainly caused some confusion and I’d like to avoid that in the future. Hence, I excluded the old version of JUnit in my POM file for this dependency.

<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-test-junit</artifactId>
    <version>${kotlin.version}</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Problem solved.