https://kotlinlang.org logo
#mockk
Title
# mockk
o

oleksiyp

05/30/2018, 4:48 PM
Don't know how complex your object is, and what do you need, here is one of useful constructs:
Copy code
class Cls {
            fun op(a: Int, b: Int) = a + b
        }
        val factory = mockk<() -> Cls>()
        every { factory().op(1, 2) } returns 2 andThen 4 andThen 5
        println(factory().op(1, 2))
        println(factory().op(1, 2))
        println(factory().op(1, 2))
Usually in tests you have fixed number of factory objects, but again depends on your case