Let’s say we have a third-party class that we are using as a type in one of our data class that we want to be serialized, then we have to write a custom serializable for
@Serializable to work.
Now the most straightforward way to go forward is to write a custom object that extends
KSerializer of type
And then use this along with the existing annotation like
But let's say our third party class contains values that are non-primitive or are in a form that we don’t want to serialize, we can write a
surrogate class to act as intermediate before encoding and decoding.
In this case, we write a Serializer for the surrogate class instead of the actual class.
And use this class as the serializer instead. Et voila
This is a simple way to mock runtime dependencies in Instrumentation tests when using Koin Library
First, let’s take a look at how an application would mostly be set up when using Koin for DI.
Now as an example, let’s take a look at some UI code that consumes these dependencies and for which we will write some Espresso tests.
In the above activity,
HomeViewModel is lazy injected using an extension function provided by Koin. …
Senior Software Engineer @ Udaan, Recro