
Generates compile-time type-safe test fakes with zero runtime overhead, no reflection, thread-safe call tracking, smart defaults and compiler-plugin code generation for comprehensive test doubles.
Automate the fake-over-mock pattern. Fakt generates type-safe test doubles that eliminate boilerplate.
@Fake
interface UserRepository {
suspend fun getUser(id: String): User
}
// Use in tests
val fake = fakeUserRepository {
getUser { id -> User(id, "Alice") }
}1. Add plugin and dependency (build.gradle.kts):
plugins {
kotlin("multiplatform") version "2.2.21" // JVM or Android also works
id("com.rsicarelli.fakt") version "x.y.z"
}
kotlin {
// ... your targets
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 build4. 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)The Tamandua eats bugs in nature. Fakt catches drift bugs at compile-time before they reach production.
Copyright (C) 2025 Rodrigo Sicarelli
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Automate the fake-over-mock pattern. Fakt generates type-safe test doubles that eliminate boilerplate.
@Fake
interface UserRepository {
suspend fun getUser(id: String): User
}
// Use in tests
val fake = fakeUserRepository {
getUser { id -> User(id, "Alice") }
}1. Add plugin and dependency (build.gradle.kts):
plugins {
kotlin("multiplatform") version "2.2.21" // JVM or Android also works
id("com.rsicarelli.fakt") version "x.y.z"
}
kotlin {
// ... your targets
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 build4. 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)The Tamandua eats bugs in nature. Fakt catches drift bugs at compile-time before they reach production.
Copyright (C) 2025 Rodrigo Sicarelli
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.