Testing in Practice: Keeping Your Tests Concise and Declarative
summary
Argues that mocks cause brittle, interaction-only tests and recommends replacing them with Kotlin idioms: factory functions for injectable constructors, functional interfaces for one-line fakes, and small focused interfaces so fakes remain simple. Shows tests that keep behavior inside a single function body, prefer object-to-object assertions over fragile property checks, and use Compose screenshot testing for pixel diffs. Claims these changes reduce setup noise, expose poor architecture, and make tests declarative and maintainable.
AI-written summary · about
chapters (17)
- 0:00Testing philosophy intro
- 1:49Automated testing types
- 3:13Unit tests and design
- 8:51Mock-heavy test critique
- 11:41Kotlin factory functions
- 13:06Functional interfaces
- 14:33Shared state avoidance
- 15:59DAMP vs DRY
- 17:00Why code is better than documentation
- 19:49Self-documenting tests
- 20:32Faking context
- 21:13Interface segregation
- 22:40Test naming
- 23:43Kotlin object mocking
- 24:25State vs properties
- 25:51Mock-free testing tips
- 27:17Outtakes
related talks
27mDe-mock your tests
19mHow to write a mock-free app
30mRefactoring and Test Fakes: Crafting Resilient Code with Confidence
37mBeyond the Mockery: Why We Should Embrace Testing Without Mocking Frameworks
36mBest Practices for Unit Testing in Kotlin
31mBeyond the Mockery- Why We Should Embrace Testing Without Mocking Frameworks
41mMocks vs Fakes vs Stubs
32mTesting with Kotlin
