Android Jetpack Compose Robolectric createComposeRule java.lang.AbstractMethodError

Viewed 31

I am trying to test compose with Robolectric. I created an example test:

@RunWith(RobolectricTestRunner::class)
class ProductDescriptionComposeTest {

    @get:Rule
    val composeTestRule = createComposeRule()

    @Test
    fun testShowMoreText() {

    }
}

And added to build.gradle:

testImplementation 'junit:junit:4.13.2'
testImplementation "org.robolectric:robolectric:4.8.1"
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'androidx.compose.ui:ui-test-junit4:1.2.1'
debugImplementation 'androidx.compose.ui:ui-test-manifest:1.2.1'

when I run it, I get:

java.lang.AbstractMethodError: Receiver class androidx.compose.ui.test.TestMonotonicFrameClock does not define or inherit an implementation of the resolved method 'abstract kotlin.coroutines.CoroutineContext$Key getKey()' of interface kotlin.coroutines.CoroutineContext$Element.
at kotlin.coroutines.CoroutineContext$plus$1.invoke(CoroutineContext.kt:33)
at kotlin.coroutines.CoroutineContext$plus$1.invoke(CoroutineContext.kt:32)

at the line:

val composeTestRule = createComposeRule()

I tried to search, but all example codes contain the same and work

0 Answers
Related