Debugging Initialization with Dependency Inversion

Опубликовано: 17 Январь 2025
на канале: Pairing with Duncan
198
29

Over the last few episodes we’ve built a tool to allow us to instrument and visualise the timeline of our test runs. Today we’ll put that to use to try to debug why our database tests are taking so long.

On the way, we have to solve the problem of allowing production code to interact with our test instrumentation. This introduces dependency inversion, where we decouple high and low level code through a shared interface.

In this episode

00:00:26 The story so far
00:01:53 Understanding the JUnit lifecycle
00:04:13 Scope functions can help us insert instrumentation
00:05:34 Top level properties are more lazy than you might think
00:06:42 Dependency Inversion to allow production code to see test instrumentation
00:07:43 IntelliJ import bug
00:11:51 Simplify the test so that we can see the wood for the trees
00:13:17 Instrumenting BeforeEach and the test runs
00:14:41 Now break down the operations
00:16:34 I wish I could read profiler output
00:17:19 How quick could we be without the DB?
00:18:18 I have a cunning plan

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

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

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

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 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.


Смотрите видео Debugging Initialization with Dependency Inversion онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Pairing with Duncan 17 Январь 2025, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 198 раз и оно понравилось 29 людям.