Why are my tests so slow? JUnit vs Gradle vs IntelliJ

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025
  • I took a test yesterday and it said that I have the reaction time of a 25 year old.
    My super speedy brain must be the reason that I find it so irritating to sit and wait for tests to complete. My MacBook Air is apparently 5.5 times faster than its equivalent 10 years ago, but I’m pretty that sure building and running the tests on a medium sized project is much less instant than it was then.
    Why are my tests so slow?
    In this episode
    00:00:27 Both the test runners are lying
    00:01:36 We can profile a Gradle build
    00:02:37 The IntelliJ runner isn't reporting build time
    00:03:28 Instrumenting the whole build and run
    00:06:00 Speeding up our Gradle build by skipping a task
    00:09:21 Running slow tests first
    00:12:44 It's still all a bit rubbish
    There is a playlist of TDD Gilded Rose episodes - • Test Driven Gilded Ros...
    and one for Gradle • Gradle
    The codebase is available on GitHub github.com/dmc...
    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 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...
    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.

ความคิดเห็น • 6

  • @DmitryKandalov
    @DmitryKandalov หลายเดือนก่อน +9

    Thank you so much for digging into the test runners' measurements! I'm sure the built-in IntelliJ test runner for Java was way faster. I might dig out an old version of IntelliJ to have proper evidence of software degradation (although sadly it doesn't feel like anyone would really care).

    • @PairingWithDuncan
      @PairingWithDuncan  หลายเดือนก่อน +3

      I couldn’t have done it without your help - a great collaboration. I don’t think most people care as much as I do, but it takes me 10 minutes a week just to remove the pauses while nothing happens in my videos!

  • @dom-
    @dom- หลายเดือนก่อน +2

    I really care about shorter feedback loops. It would be great to have all those tests run below 1s, even if it's just a psychological barrier.

    • @PairingWithDuncan
      @PairingWithDuncan  หลายเดือนก่อน +2

      Absolutely. Once you’ve experienced TDD with really fast feedback you don’t want to go back.