
Fakt: Automating the Fake-over-mock pattern
Kotlin testing has a problem that gets worse the more successful your project becomes. Manual test fakes don't scale—each interface requires 60-80 lines of boilerplate that silently drifts from reality during refactoring. Runtime mocking frameworks (MockK, Mockito) solve the boilerplate but introduce severe performance penalties and don't work on Kotlin/Native or WebAssembly. KSP-based tools promised compile-time generation, but Kotlin 2.0 broke them all. Fakt is a compiler plugin that generates production-quality fakes through deep integration with Kotlin's FIR and IR compilation phases—the same extension points used by Metro , a production DI framework from Zac Sweers. What Fakt Does https://github.com/rsicarelli/fakt Fakt reduces fake boilerplate to an annotation: @Fake interface AnalyticsService { fun track ( event : String ) suspend fun flush (): Result < Unit > } At compile time, Fakt generates a complete fake implementation. You use it through a type-safe factory: val fake = fak
Continue reading on Dev.to
Opens in a new tab



