Turbocharge Testing with JUnit, Gradle & IntelliJ

Published: 06 December 2024
on channel: Pairing with Duncan
607
45

If you’ve watched any of my previous videos then you will probably know that I practice Test Driven Development. To some extent just having to write tests makes our code better, but, what the hell, we might as well run them to find out if things actually work.

If we are going to run the tests, then waiting for them is just a drag. When I’m coding I’ll often run the tests more than once a minute, and if they take longer than a second or so then they interrupt my flow and hurt my productivity. Introducing Testcontainers last episode (   • Testcontainers, Postgres, Kotlin  ) made it apparent just how much I hate slow tests, so this week I’m going to look at techniques for keeping our inner loop as short as possible.

In this episode

00:00:38 Fixing our Testcontainer image
00:01:30 Tests are now too slow
00:02:25 IntelliJ's test runner
00:05:04 Gradle's test runner
00:06:04 Comparing the two runners
00:06:52 IntelliJ test runner bug
00:07:34 Rerunning tests from the command line
00:09:46 Normally skip slow tests
00:11:54 Disabled tests are useful for manual tasks and checks
00:13:51 Parallel testing
00:17:12 Preventing parallel tests
00:18:02 Dmitry's test runner plugin

There is a playlist of TDD Gilded Rose episodes -    • Test Driven Gilded Rose in Kotlin  
and one for Gradle    • Gradle  

The codebase is available on GitHub https://github.com/dmcg/gilded-rose-tdd

I get lots of questions about the test progress bar. It was written by the inimitable @dmitrykandalov. To use it install his Liveplugin (https://plugins.jetbrains.com/plugin/...) and then this gist https://gist.github.com/dmcg/1f56ac39...

If you are going to be at KotlinConf 2025, or even just in Copenhagen in May, then you should sign up for the workshop that Nat Pryce and I are running. It’s called Refactoring to Functional Kotlin, and will give you hands-on experience of taking legacy code and safely migrating it to a functional style. Places are limited, so buy now at https://kotlinconf.com/workhops

If you like this video, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook (http://java-to-kotlin.dev). It's about far more than just the syntax differences between the languages - it shows how to upgrade your thinking to a more functional style.


Watch video Turbocharge Testing with JUnit, Gradle & IntelliJ online without registration, duration hours minute second in high quality. This video was added by user Pairing with Duncan 06 December 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 607 once and liked it 45 people.