Automate the fake-over-mock pattern. Fakt generates type-safe test doubles that eliminate boilerplate.
@Fake
interface UserRepository {
suspend fun getUser(id: String): User
}
val fake = fakeUserRepository {
getUser { id -> User(id, "Alice") }
}
🤔 Why Fakt?
- Manual fakes scale poorly - Each type needs custom tracking, config, or cleanup code
- Manual fakes rot over time - Behavior diverges from real implementations without compile-time warnings
- - Testing how dependencies are called, not what code achieves
✨ Key Features
- Zero boilerplate - Compiler generates type-safe fakes automatically at build time
- Never drift from real code - Interface changes cause compile errors, not silent bugs
- Test what matters - Verify outcomes (state) instead of implementation details (calls)
- Works everywhere - All KMP targets without reflection, zero production dependencies
⚡ Quick Start
1. Add plugin and dependency (build.gradle.kts):
plugins {
kotlin("multiplatform") version "2.3.20"
id("com.rsicarelli.fakt") version "x.y.z"
}
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("com.rsicarelli.fakt:annotations:x.y.z")
}
}
}
}
2. Annotate interface:
import com.rsicarelli.fakt.Fake
@Fake
interface Analytics {
suspend fun track(event: String)
}
3. Build the project:
./gradlew build
4. Use in tests:
val events = mutableListOf<String>()
val fake = fakeAnalytics {
track { event -> events.add(event) }
}
fake.track("user_signup")
assertEquals(listOf("user_signup"), events)
assertEquals(1, fake.trackCalls.value.size)
🤝 Contributing
- Report Bugs: Bug Report
- Discuss & Suggest: GitHub Discussions - Ask questions, propose ideas, share work — your input shapes the roadmap!
- Documentation:
🐜 Our Mascot
The Tamandua eats bugs in nature. Fakt catches drift bugs at compile-time before they reach production.
License
Copyright (C) 2025 Rodrigo Sicarelli
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
https:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.