Closed HzKrym closed 11 months ago
Is it possible to do this?
No, because of val result = interactor.setFoo(expectedResult)
- setFoo()
doesn't return anything. And to be honest you shouldn't write tests like this IMHO. This design is (sorry to say this) a bit strange. Do you have a more concrete example?
If I were to verify a setter in this simple case I would just set the value and assert against it. No need to mock the Repository
. Just create an anonymous object and a fake implementation of it:
@Parameters(value = ["foo", "bar"])
fun testSetter(expectedResult: String) {
val repo = object : Repository {
var fooValue: <WhateverObjectThisShouldBe>
override fun setFoo(value) { fooValue = value }
override fun getFoo() = fooValue
}
val interactor = Interactor(repo)
interactor.setFoo(expectedResult)
assertEquals(interactor.getFoo(), expectedResult)
}
Is it possible to do this?