Debugging Initialization with Dependency Inversion
ฝัง
- เผยแพร่เมื่อ 10 ก.พ. 2025
- 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 Ros...
and one for testing • Testing
The codebase is available on GitHub github.com/dmc...
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 kotlinconf.com...
I get lots of questions about the test progress bar. It was written by the inimitable @dmitrykandalov. To use it install his Liveplugin (plugins.jetbra...) and then this gist gist.github.co...
If you like this video, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook (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.
Very good video, I was betting my horse on Hikari pool initialisation...
On another note, it would be great to have Lukas again!
Thank you. I think that creating the connection is about 200ms of the time - there is a discussion (with Lukas:-) here github.com/jOOQ/jOOQ/issues/17884