如何模拟Kotlin Singleton类?

时间:2018-10-31 05:26:15

标签: android kotlin mockito powermockito

如何模拟Singleton类? 单例课程如下:

class Singleton private constructor() {
    init { println("This ($this) is a singleton") }    

    private object Holder { val INSTANCE = Singleton() }

    companion object {
        val instance: Singleton by lazy { Holder.INSTANCE }
    }
    var b:String? = null
}

0 个答案:

没有答案