Getting `Could not find androidx.annotation:annota...
# compose-desktop
t
Getting
Could not find androidx.annotation:annotation:1.1.0
when test executed. 🧵
I tried to create a simple test using
Copy code
testImplementation(compose("org.jetbrains.compose.ui:ui-test-junit4"))
but am getting
Copy code
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find androidx.annotation:annotation:1.1.0.
Here's my test
Copy code
import androidx.compose.material.Text
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.Rule
import org.junit.jupiter.api.Test

class SplashScreenTest {
    @get:Rule
    val composeRule = createComposeRule()

    @Test
    fun `My Test`() {
        runBlocking(Dispatchers.Main) {
            composeRule.setContent {
                Text(text = "Something")
            }

            composeRule.onNodeWithText("Something").assertExists()
        }
    }
}
Feel free to ask more information if needed.
i
Will this help?
t
Ohh yes. that fixed the dependency issue, but am getting another error now
Copy code
lateinit property window has not been initialized
kotlin.UninitializedPropertyAccessException: lateinit property window has not been initialized
	at androidx.compose.ui.test.junit4.DesktopComposeTestRule.getWindow(DesktopComposeTestRule.desktop.kt:64)
	at androidx.compose.ui.test.junit4.DesktopComposeTestRule.setContent(DesktopComposeTestRule.desktop.kt:146)
i
Do you use
createComposeRule
this way?
Copy code
@get:Rule
val rule = createComposeRule()
t
Yes. u can see that in the above code.
i
import org.junit.jupiter.api.Test
Maybe this is because you are using Junit 5. We didn't test Compose with it.
t
Ohh I see.. Downgrading to junit4 worked. 👍 Thank you 🙂
150 Views