Skip to content

Sample Projects

Fakt includes working sample projects demonstrating different use cases.


jvm-single-module

Location: samples/jvm-single-module/

Demonstrates: JVM-only projects with standard kotlin-jvm plugin

Targets: JVM only

Key Examples:

  • UserRepository (CRUD with call tracking)
  • AuthenticationService (suspend functions + Result types)
  • PropertyAndMethodInterface (properties + methods)
  • No platform-specific setup required

Best for: Learning Fakt basics without KMP complexity


android-single-module

Location: samples/android-single-module/

Demonstrates: Android Library projects with AGP integration

Targets: Android (compileSdk=35, minSdk=24)

Key Examples:

  • Same scenarios as jvm-single-module for consistency
  • Unit tests in src/test/kotlin
  • Instrumented tests support in src/androidTest/kotlin
  • Works with Android Gradle Plugin 8.12.3+

Best for: Android developers wanting test fakes without KMP


kmp-single-module

Location: samples/kmp-single-module/

Demonstrates: Basic KMP usage with single module

Targets: JVM, iOS, Android, JS, Native

Key Examples:

  • Simple interfaces with suspend functions
  • Property fakes (val/var)
  • Generic interfaces
  • Call tracking with StateFlow

Best for: Learning Fakt basics and KMP setup


kmp-multi-module

Location: samples/kmp-multi-module/

Demonstrates: Advanced multi-module architecture with dedicated fake modules

Structure:

  • 11 producer modules with @Fake interfaces
  • 11 dedicated -fakes collector modules
  • 1 consumer app module using all fakes

Key Examples:

  • Cross-module fake consumption (experimental)
  • Gradle project references with version catalogs
  • Large-scale KMP project patterns
  • Fake module organization

Best for: Understanding multi-module setups and scaling Fakt


kmp-multi-target

Location: samples/kmp-multi-target/

Demonstrates: KMP source set hierarchy validation and platform-specific fake generation

Structure:

  • 6 platform-specific @Fake interfaces (one per source set)
  • 11 test classes (6 basic + 5 hierarchy validation)
  • 45+ test cases validating fake generation and hierarchy

Key Validations:

  • ✅ Platform-specific fake generation (jvmMain → jvmTest, iosMain → iosTest)
  • ✅ Vertical hierarchy (child source sets access parent fakes)
  • ✅ Multi-level inheritance (iOS accesses commonMain + nativeMain + iosMain)
  • ✅ Horizontal isolation (jvmTest cannot access iosFakes)

Source Sets Tested:

  • commonMaincommonTest (base for all platforms)
  • jvmMainjvmTest (JVM-specific)
  • iosMainiosTest (iOS-specific, inherits from nativeMain)
  • jsMainjsTest (JavaScript-specific)
  • wasmJsMainwasmJsTest (WebAssembly-specific)
  • nativeMainnativeTest (shared across all native targets)

Best for: Validating Fakt’s source set mapping and KMP hierarchy support


Running Samples

Clone the repository and build:

git clone https://github.com/rsicarelli/fakt.git

# JVM-only sample
cd fakt/samples/jvm-single-module
./gradlew build

# Android sample
cd fakt/samples/android-single-module
./gradlew build

# KMP samples
cd fakt/samples/kmp-single-module
./gradlew build

# KMP hierarchy validation
cd fakt/samples/kmp-multi-target
./gradlew allTests

Next Steps