Closed serpro69 closed 8 months ago
OK, so one reason to consider returning "predefined instance" before "default instance" would be to allow generating abstract classes:
abstract class TestAbstractClass(
val id: Int,
val name: String,
)
val testAbsClass = faker{}.randomProvider.randomClassInstance<TestAbstractClass> {
typeGenerator<TestAbstractClass> {
object : TestAbstractClass(42, "Deep Thought") {}
}
}
testAbsClass.id shouldBe 42
testAbsClass.name shouldBe "Deep Thought"
The question is - is it a good enough reason? Would anyone ever want to directly initialize an abstract class?
Closes #201
Still not sure what the precedence should be, but I think it makes more sense to first try a default instance with public constructor. But I could probably as easy argue for the other way around , so I'm really just winging it here :D