Eduard Boloș
01/31/2024, 6:34 PMclass Sut(val dep1: Dep1, val dep2: Dep2) {
fun foo(): A {
dep1.bar()
return dep2.baz()
}
}
class Dep1 {
fun bar() {
// ...
}
}
class Dep2 {
fun baz(): A {
// ...
}
}
class SutTest {
val dep1 = mockk<Dep1>()
val dep2 = mockk<Dep2>()
val sut = Sut(dep1, dep2)
@Test
fun `test foo`() {
every { dep2.baz() } returns A()
sut.foo() // <-- this calls dep1.bar, which is not stubbed, and yet it doesn't throw
verify { dep1.bar() }
}
Shouldn't sut.foo()
throw because it calls the non-stubbed dep1.bar()
, since we didn't set relaxed = true
on it?Mattia Tommasone
02/01/2024, 7:30 AMEduard Boloș
02/01/2024, 7:33 AM