Repository navigation
Create compat-kotlin-fixture module for AppMattus KotlinFixture migration #62
Description
Description
Problem: Teams using AppMattus KotlinFixture who want to migrate to Some must rewrite their test data generation code. The two libraries have similar capabilities but incompatible APIs (kotlinFixture() vs someSetup(), fixture<T>() vs some<T>(), repeatCount vs CollectionStrategy, etc.). This creates friction and blocks adoption.
User benefit: A dedicated compat module lets users migrate by changing only their Gradle dependency and import statements. All existing AppMattus patterns continue to work as thin aliases over Some's resolver chain.
Proposed solution: Add a new Gradle module compat-kotlin-fixture (artifact: dev.appoutlet:some-compat-kotlin-fixture) that depends on the core some artifact and provides extension functions / wrapper classes mapping the AppMattus public API to Some internals. The module is pure Kotlin with no additional runtime dependencies.
Scope
In scope:
- New Gradle module
compat-kotlin-fixtureunder repository root with its ownbuild.gradle.kts - Top-level
kotlinFixture()factory returning a wrapper aroundSome Fixturetype alias / wrapper withinvoke()overloads:fixture<T>()→some<T>()fixture(listOf(...))→ random element from listfixture(1..5)→ random element from rangefixture.asSequence<T>()→Sequence<T>generationfixture.new { }→ derived fixture configuration
- Configuration DSL aliases:
repeatCount { }→CollectionStrategysubType<Super, Sub>()→ type factory registrationfactory<T> { }→factory(KClass) { }property(PropertyRef) { }→property(KProperty1) { }filter<T> { }→ sequence filteringrandom = Random(seed)→seednullabilityStrategy(...)→NullableStrategymappingoptionalStrategy(...)→DefaultValueStrategymappingrecursionStrategy(...)→ circular reference handling
- Strategy enum/object aliases (e.g.,
NeverNullStrategy→NullableStrategy.NeverNull) - Unit tests proving each alias produces the same behavior as the native Some API
- Dokka documentation and a short migration guide
Out of scope (initial release):
loggingStrategy(no equivalent in Some today)constructorStrategy(no equivalent in Some today)fixture-javafaker/fixture-generex/fixture-kotestintegrations- Android-specific test artifacts
Acceptance criteria
- GIVEN a user has
com.appmattus.fixturecode usingkotlinFixture()andfixture<T>()
WHEN they replace the dependency withdev.appoutlet:some-compat-kotlin-fixtureand update imports todev.appoutlet.some.compat.kotlinfixture.*
THEN the code compiles and generates the same fixture shapes without further changes - GIVEN a user configures an AppMattus fixture with
repeatCount { 3 },factory<Int> { 42 }, andnullabilityStrategy(NeverNullStrategy)
WHEN the compat layer builds the underlyingSomeConfig
THENsome<List<String>>()produces exactly 3 items,some<Int>()always returns42, andsome<String?>()never returnsnull - GIVEN the
compat-kotlin-fixturemodule is added to the project
WHEN./gradlew :compat-kotlin-fixture:testruns
THEN all compat layer tests pass and Kover line coverage for the new module is ≥ 90% - GIVEN a user calls
fixture.asSequence<User>().take(5).toList()through the compat API
WHEN the sequence is consumed
THEN it produces 5 distinct generatedUserinstances via the same resolver chain assome<User>()
Activity