When I started learning Mockk for testing, I had the following question.
Mockk official sample shows like:
val car = mockk<Car>()
and
val car = mockkClass(Car::class)
I seem the two as the same. What's the difference?
When I started learning Mockk for testing, I had the following question.
Mockk official sample shows like:
val car = mockk<Car>()
and
val car = mockkClass(Car::class)
I seem the two as the same. What's the difference?
The difference is that the first mock instantiation method takes a type argument, and the second takes a class reference KClass.
So in practice, those examples produce the same result, but I guess the second one has a higher degree of freedom to decouple the class being mocked during runtime.