I want to test class B:
class B : A {
override fun init() {
// do work here
}
}
class A {
protected fun init() { } // will be called by internal logic
}
在Java中,在测试方法(test class is in the same package as test subject)中调用:b.init()
是没有问题的,但在Kotlin编译器中,它抱怨:
无法访问"init":它在"B"中受保护
@Test
fun `checks init`() {
val b = B()
b.init()
// assert work done
}
Why isn't it working? How can this be workaround (I want to avoid making method public)?