Testing Tricks with Kotlin
summary
Kotlin test hacks that speed up debugging: enable Gradle configuration cache to make repeated runs much faster, use IntelliJ’s run automatically and Control‑Shift‑R to rerun focused tests, and name tests with backticks for readable assertions. Mocking adds a big startup cost because mocking libs attach a byte-buddy agent (observed ~600 ms vs 1–4 ms for a fake), and mocking can introduce memory leaks. Diagnose leaks with a VisualVM heap dump (found 10M User instances held by an ever‑growing list). Use Roborazzi/Roboelectric for screenshot golden diffs.
AI-written summary · about
chapters (22)
- 0:00Testing with Kotlin
- 2:32Gradle cache for faster tests
- 3:56Fixing failing tests
- 5:21Auto-run tests in IntelliJ
- 6:46Stack traces in logs
- 7:07Readable test names
- 8:10Test coverage in IDE
- 9:33Test shortcuts
- 9:53Mocking vs faking
- 11:16Mocking libraries overhead
- 12:22Dynamic mock complexity
- 14:36Memory leaks in tests
- 17:47Heap dumps with VisualVM
- 20:54Mocking memory leaks
- 21:15Flaky tests with Gradle
- 22:59Debugging coroutines
- 25:50DI and test scopes
- 28:16Screenshot testing
- 31:54Golden images for UI
- 32:58Mocking Android APIs
- 34:44Avoid Robolectric
- 35:28Closing remarks








