Hello everyone, Did someone managed to unit test `...
# announcements
g
Hello everyone, Did someone managed to unit test
object
classes ? We would like, for each test, re init a
lateinit var foo
property with different values a on our singleton, but actually, once it is initialized once, we found no way to reinit the singleton. Sorry for my english..
a
What do you mean with initalize? Its a
var
, so you can just set a new value
g
You can mock object using static mocking with Mockk http://mockk.io/ Or something like Power Mock
But my (and not only my) opinion that you shouldn’t do this. If you want to mock object, top level function, constant etc you are doing something wrong and should think about architecture of your testable class.
2
👍 2
g
Thank you @gildor ! Yeah, you're right. It is just to go a bit further in unit tests with Kotlin, trying to see what's possible and not. Thank you for your time.