Hi everyone!
I'm having some trouble setting up unit tests for Android in Kotest and MockK.
I recently joined a company who already has an android application which did not contain any unit tests. The code is not made with testability in mind so I'm having some trouble. I recently fixed something in a Fragment so I improved the code but I wouldn't call it great. I would like to write tests for it now.
Currently I want to test a kotlin function which calls code like this. The other classes are in Java.
ClassWithManyStaticMethods.getSomething().method(lateInitialisedField)
I finally figured out how to mock the static class but stumble upon following error
lateinit property lateInitialisedField has not been initialized
 .
So the 
lateInitialisedField
  is a lateinit in the class I want to test. When I call the function I want to test, the 
lateInitialisedField
 is not initialised.
How do I initialise it in the test or prevent the error? The value does not matter for my test, I just want to verify if 
method
 has been called.
I tried using 
@InjectMocks
 when I create the class under test and created a mockk 
lateInitialisedField
  in my test but either I'm doing something wrong or this is not the solution.
If anyone could point me in the right direction that would be greatly appreciated!