My code saves an object to database in some bigger method, but I don't need to test this.
So I want to mock the Repository.save method. But the save
method returns the saved object.
I tried the following:
@MockK
private lateinit var mockJobRepository: JobRepository
val jobSlot = slot<Job>()
// ...
every { mockJobRepository.save<Job>(capture(jobSlot)) }
returns(jobSlot.captured)
But it throws an runtime error: "lateinit property captured has not been initialized"
How do I just return the given argument in the mock?
Have you tried
?
I've notice @Mockk annotations on lateinit vars can be finicky