How to mock a Kotlin singleton object?
There’s a very nice mocking library for Kotlin – Mockk, which allows you to mock objects, the exact same way you’re desiring. As of its documentation: Objects can be transformed to mocks following way: object MockObj { fun add(a: Int, b: Int) = a + b } mockkObject(MockObj) // aplies mocking to an Object assertEquals(3, … Read more