如何简单地模拟不同的android版本的同一个类?
此示例在运行第二种测试方法时引发io.mockk.MockKException: Can't instantiate proxy for class androidx.core.app.NotificationCompat$Builder
异常。
@RunWith(AndroidJUnit4::class)
class test {
@Test
@Config(sdk = [Build.VERSION_CODES.O], application = Application::class)
fun test1() {
val builder: NotificationCompat.Builder = mockk()
}
@Test
@Config(sdk = [Build.VERSION_CODES.N], application = Application::class)
fun test2() {
val builder: NotificationCompat.Builder = mockk()
}
}