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.
Смотрите видео Turbocharge Testing with JUnit, Gradle & IntelliJ онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Pairing with Duncan 06 Декабрь 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 607 раз и оно понравилось 45 людям.