4

for example the method

   class SomeClass() {
       fun login(listener: (Boolean) -> Unit ) {
            do some async logic and then call the listener with the result
      }
   }

   val spy = spyk(SomeClass())  {

          val completion = slot<(Boolean) -> Unit>()
         //this immediately calls the original login method
         every { login(capture(completion)) } answers {
              completion.captured.invoke(true)
         }
     }

trying to stub the login method immediately invokes it.

Do you know how to just stub it and not invoke it?

Lena Bru
  • 13,521
  • 11
  • 61
  • 126

1 Answers1

0

If we look at the Mockk, maybe relaxed-mock ?

MaTriXy
  • 1,659
  • 1
  • 20
  • 27