【发布时间】:2020-11-02 16:44:11
【问题描述】:
我使用 Junit4 和 kotlin。
我使用 Enclosed 进行内部类测试。
import org.junit.Test
import org.junit.experimental.runners.Enclosed
import org.junit.runner.RunWith
@RunWith(Enclosed::class)
class SampleTest {
var text = "parent class"
class Class1 {
@Test
fun `print the text`() {
println(text)
}
}
inner class Class2 {
@Test
fun `print the text`() {
println(text)
}
}
}
在 Class1 和 Class2 中,需要 text 变量。
我使用inner 来访问子类到父类。
但是我有一个问题,测试功能被删除了,我无法测试它。看照片。
我可以用 Junit4 测试高岭土的内部类吗?
【问题讨论】:
标签: android unit-testing kotlin testing junit