xenomachina
09/19/2023, 11:43 PMevery { implementedMethod() } answers { callOriginal() }
for every single implemented method/property?Klitos Kyriacou
09/20/2023, 8:19 AMxenomachina
09/20/2023, 4:35 PMKlitos Kyriacou
09/20/2023, 5:00 PMspyk
which can spy on abstract classes. It's not exactly what you want as it makes abstract methods have default behaviour instead of throwing an exception. That default behaviour is to do nothing for functions returning Unit, return 0 for integral return values, and null for objects (even for return types that are non-nullable!)xenomachina
09/20/2023, 5:22 PMspyk
for abstract methods?xenomachina
09/20/2023, 5:30 PMfun mockConfig() : Config {
val props = AbstractTestConfig::class.memberProperties
return mockk<AbstractTestConfig> {
props.forEach { prop ->
every { prop.get(this@mockk) } answers { callOriginal() }
}
}
}
but this seems to have the same problem: abstract properties return 0 or null.
It also strangely did not seem to "see" the overrides in AbstractTestConfig
. It treated those properties the same way it treated abstract properties.