KotlinLeaner
02/23/2023, 2:11 PMval dispatcherModule = module {
// Dispatchers
single(named(DISPATCHER_IO)) {
<http://Dispatchers.IO|Dispatchers.IO>
}
}
// some other place to use startKoin
startKoin { modules(
listOf(dispatcherModule)) }
class PairViewModelTest {
@get:Rule
val testInstantTaskExecutorRule: TestRule = TestMainCoroutineRule()
@get:Rule
val koinTestRule = KoinTestRule.create {
modules(dispatcherModule)
}
@MockK private lateinit var mockCoroutineDispatcher: CoroutineDispatcher
private val subject by lazy { spyk(PairViewModelTest(mockCoroutineDispatcher))}
@Before
fun setUp() {
MockKAnnotations.init(this, relaxed = true)
loadKoinModules(module {
factory {
mockCoroutineDispatcher
}
})
}
/// more test here which is failed
}
my all tests are failedclass java.lang.Object cannot be cast to class java.lang.Boolean (java.lang.Object and java.lang.Boolean are in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class java.lang.Object cannot be cast to class java.lang.Boolean (java.lang.Object and java.lang.Boolean are in module java.base of loader 'bootstrap')
abbic
02/23/2023, 2:47 PMKotlinLeaner
02/23/2023, 2:53 PMabbic
02/23/2023, 3:51 PMKotlinLeaner
02/23/2023, 5:59 PM