DI pattern. I'm mocking the method exactly to avoid initializing the dependency, yet once I do
Copy code
every { myService.methodUsingX() } ...
I get
lateinit property x has not been initialized
. Is this expected?
m
Mattia Tommasone
04/12/2023, 10:50 AM
i don’t know much about spring-mockk so i don’t know if it’s expected to work with @Autowired dependencies or not
Mattia Tommasone
04/12/2023, 10:50 AM
but if you switch to constructor injection rather than @Autowired injection it’s still supported by spring and you can inject mocked objects in your tests
d
David Kubecka
04/12/2023, 11:38 AM
My bad. This test doesn't use spring-mock at all.
myService
is instatiated explicitly. And that was the problem - I forgot wrapping it with