Tag: 验证错误

java.lang.VerifyError在Kotlin中编写Android测试的特性

我正在尝试为Android的InstrumentationTestCase创建一个包含抽象属性和使用此属性的方法的特征。 不幸的是,当我运行这个测试它崩溃与java.lang.VerifyError 。 所以这是一个导致崩溃的代码示例: trait ExtendedInstrumentationTestCase : InstrumentationTestCase { val string: String fun printString(): Unit { println(string) } } class MyApplicationTestCase : ApplicationTestCase<Application>(javaClass<Application>()), ExtendedInstrumentationTestCase { override val string: String = "test" override fun setUp() { super<ApplicationTestCase>.setUp() printString() } override fun tearDown() { super<ApplicationTestCase>.tearDown() } } 这就是我从logcat得到的结果: W/dalvikvm﹕ VFY: Lcom/kotlintest/MyApplicationTestCase; is not instance of Landroid/test/InstrumentationTestCase; W/dalvikvm﹕ […]