Hello! I am running into something which I believe...
# mockk
e
Hello! I am running into something which I believe to be unexpected. Basically, I have a mock which in the test has a non-stubbed method invoked, and I was expecting it to throw as a consequence, but it doesn't. Is my expectation wrong? Here's a quick draft to illustrate:
Copy code
class 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?
m
could it be you configured your mocks to always be relaxed in mockk.properties?
e
We don't have such a file.