MokkeryStubsOptions
When mocking an abstract or open class, its constructor may require arguments. Since Mokkery must invoke this constructor, all required parameters must be provided.
Mokkery uses the following strategies to supply constructor arguments:
nullfor nullable types0for all numeric typesfalseforBoolean'\u0000'forCharAny()forAnyA
kotlin.reflect.KClassinstance matching the required type (e.g.Int::classforKClass<Int>)The
Unitobject forUnitEmpty arrays for all array types
Empty collections for
Iterable,Collection,List,Set,Map, and their mutable counterpartsThe first declared entry for enum types
Lambdas that return values resolved using the same strategies
Generated stub implementations for interfaces
Instantiating concrete classes using available constructors, following the same rules. By default, this works only for inline classes,
Throwablesubclasses, and classes fromkotlin.collections,kotlin.sequences, andkotlin.ranges. For other types, explicit permission is required because invoking constructors may execute unintended code during tests. Public and internal constructors are supported, with default constructors preferred. Enable this behavior in your Gradle build file using themokkery.stubs.allowConcreteClassInstantiationflag.Generating stub implementations for classes. This requires explicit permission for the same reason as concrete classes instantiation. Enable this behavior in your Gradle build file using
mokkery.stubs.allowClassInheritanceflag.
Mokkery selects the first applicable strategy based on the order listed above.