Idiomatic Kotlin in Tests
summary
Examples show stepwise refactors from Java JUnit tests to Kotlin using IntelliJ Java→Kotlin converter, replacing JUnit patterns with Kotest stringSpec and forAll for DSL test suites and parameterized lists, swapping Mockito boilerplate for mockito-kotlin or MockK inline mocks and infix assertions, and replacing assertThrows with runCatching/result-based exception assertions so tests become type-safe (data classes for inputs), less noisy, and allow grouped soft assertions and richer failure reports.
AI-written summary · about
chapters (6)
- 0:00Introduction to idiomatic Kotlin tests
- 1:07Refactoring Spring REST controller test
- 9:24Parameterized price mapper test
- 15:40Testing exception handling
- 19:19Key takeaways and libraries
- 23:46Further resources and closing
related talks
32mTesting with Kotlin
28mTesting Out Kotlin
41mTesting in Kotlin: The Holy Grail of Readability and Power
15mKotlin for Test Automation
36mBest Practices for Unit Testing in Kotlin
54mKotlin all the... tests!
42mExcuse Me, Sir, Do You Have a Moment to Talk About Tests in Kotlin?
43mEffective Unit testing with Kotlin
