How to write unit test for null object using kotlin scope function

Viewed 21

I am writing unit test for the onLifecycleResumed(). I want to write test if my randomId is null. As you can see in the code snippet that I have used scope function. I would like to have some insight on how to write unit test for the nullable object.

private var randomId: String? = null

override fun onLifecycleResumed() {
    super.onLifecycleResumed()
    randomId?.also {
        //do something
    }
}
0 Answers
Related