Plugin Configuration¶
Complete reference for configuring the Fakt Gradle plugin.
Complete Configuration Reference¶
All available configuration options in your module’s build.gradle.kts:
// build.gradle.kts
import com.rsicarelli.fakt.compiler.api.LogLevel
plugins {
alias(libs.plugins.fakt)
}
fakt {
// Enable or disable the plugin (default: true)
enabled.set(true)
// Control logging verbosity (default: INFO)
logLevel.set(LogLevel.INFO) // Options: QUIET, INFO, DEBUG
// Control call history generation (default: true)
enableCallHistory.set(true) // Set to false for lightweight fakes
// Control mutable fake generation (default: false)
enableMutableFakes.set(false) // Set to true for mutable fakes by default
// Generate fakes to testFixtures source set (default: false, JVM only)
useGradleTestFixtures.set(false) // Requires `java-test-fixtures` plugin
// Multi-module: Collect fakes from another module (default: not set)
@OptIn(com.rsicarelli.fakt.compiler.api.ExperimentalFaktMultiModule::class)
collectFakesFrom(projects.core.analytics)
}
Configuration Properties¶
| Flag | Default | Example |
|---|---|---|
| enabled | true |
|
| logLevel | INFO |
|
| enableCallHistory | true |
|
| enableMutableFakes | false |
|
| useGradleTestFixtures | false |
|
| collectFrom | Not set |
Log Level Details¶
Call History Configuration¶
Control whether generated fakes include call tracking and verification capabilities.
| Setting | Description | Example |
|---|---|---|
| true (default) |
Full call history with: - `methodNameCalls` StateFlow properties - `methodNameCallHistory` lists - `verifyMethodName { }` DSL | |
| false | Lightweight fakes with only behavior configuration. No call history overhead. |
Per-Interface Override¶
Individual interfaces can override the project default:
import com.rsicarelli.fakt.CallHistoryMode
// Always generate call history (even if plugin default is false)
@Fake(callHistory = CallHistoryMode.ENABLED)
interface PaymentService { ... }
// Never generate call history (even if plugin default is true)
@Fake(callHistory = CallHistoryMode.DISABLED)
interface Logger { ... }
// Follow plugin default
@Fake // or @Fake(callHistory = CallHistoryMode.DEFAULT)
interface UserService { ... }
Resolution order: Annotation setting takes precedence over plugin default.
Mutable Fakes Configuration¶
Control whether generated fakes are mutable (reconfigurable mid-test) or immutable (fixed at construction). For an in-depth exploration of when to use each mode, see Immutable vs Mutable.
| Setting | Description | Example |
|---|---|---|
| false (default) |
Immutable fakes with: - `private val` behavior properties - Behavior fixed at construction time - No `modify {}` method | |
| true | Mutable fakes with: - `@Volatile private var` behavior properties - `modify {}` method for selective reconfiguration - Mid-test behavior changes |
Per-Interface Override¶
Individual interfaces can override the project default:
import com.rsicarelli.fakt.MutabilityMode
// Always generate mutable fake (even if plugin default is false)
@Fake(mutability = MutabilityMode.MUTABLE)
interface UserRepository { ... }
// Always generate immutable fake (even if plugin default is true)
@Fake(mutability = MutabilityMode.IMMUTABLE)
interface Logger { ... }
// Follow plugin default
@Fake // or @Fake(mutability = MutabilityMode.DEFAULT)
interface UserService { ... }
Resolution order: Annotation setting takes precedence over plugin default.
Multi-Module Configuration¶
| Mode | Example |
|---|---|
| Type-safe accessor | |
| String-based path |
For complete multi-module documentation, see Multi-Module Guide.
IDE Integration¶
IntelliJ IDEA / Android Studio¶
Generated fakes appear in build/generated/fakt/ and are automatically indexed.
Enable K2 Mode for better autocomplete:
- Settings → Languages & Frameworks → Kotlin
- Enable K2 mode
- Restart IDE
K2 mode improves factory function autocomplete and type inference.
Generated Sources Location¶
| Source Set | Generated Output |
|---|---|
commonTest/ |
build/generated/fakt/commonTest/kotlin/ |
jvmTest/ |
build/generated/fakt/jvmTest/kotlin/ |
iosTest/ |
build/generated/fakt/iosTest/kotlin/ |
androidUnitTest/ |
build/generated/fakt/androidUnitTest/kotlin/ |
testFixtures/ |
build/generated/fakt/testFixtures/kotlin/ (requires useGradleTestFixtures) |
Next Steps¶
- Test Fixtures (JVM) - Cross-module fakes for JVM projects
- Multi-Module (KMP) - Cross-module fakes with collector modules
- Usage Guide - Comprehensive usage patterns and examples
- Troubleshooting - Common configuration issues