Jilles van Gurp
03/26/2021, 1:08 PMBig Chungus
03/26/2021, 1:10 PMJoost Klitsie
03/26/2021, 1:37 PMBig Chungus
03/26/2021, 2:03 PM// src/main/kotlin
interface ImportantObject {
fun check(): Boolean
}
class ImportantObjectImpl: ImportantObject {
private val actualImplementationReturn: Boolean = true
override fun check(): Boolean = actualImplementationReturn
}
class Processor {
fun process(importantObject: ImportantObject): Boolean {
return importantObject.check()
}
}
fun main() {
Processor().process(ImportantObjectImpl()) // returns true
}
And in tests you can then do
// src/test/kotlin
class ImportantObjectTest {
@Test
fun test() {
Processor().process(object: ImportantObject {
override fun check(): Boolean = false
}) // returns false
}
}
Jilles van Gurp
03/29/2021, 8:53 PMBig Chungus
03/29/2021, 8:59 PMJilles van Gurp
03/30/2021, 7:40 AMBig Chungus
03/30/2021, 7:53 AM