0

I'm attempting a Kotlin Compose Multiplatform project and want to write a unit test for a piece of @Composable UI in my commonMain project. From the references I've found online, I should be able to do the following:


@get:Rule
val compose = createComposeRule()

But I haven't been able to find the right dependency to have createComposeRule show up as a valid function.

My current build.gradle.kts has this (just displaying applicable points):

plugins {
   kotlin("multiplatform") version "1.7.10"
   id("org.jetbrains.compose") version "1.3.0"
}

kotlin {
   sourceSets {
      val commonTest by getting {
         dependencies {
            implementation(kotlin("test"))
            implementation(kotlin("test-junit"))
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
            implementation(compose("org.jetbrains.compose.ui:ui-test-junit4"))
         }
      }
   }
}

Is there an available dependency or version I'm missing to make createComposeRule available, or should I be using a different type of UI test for this source set?

Jesser
  • 76
  • 7

1 Answers1

1

Try to include compose junit4 dependency this way in Gradle

implementation(compose.uiTestJUnit4)
  • I'm getting below error. "Could not find org.jetbrains.compose.ui:ui-test-junit4-uikitarm64:1.4.3" – Mohammed Aug 09 '23 at 14:34
  • I am also getting the same error "Could not find org.jetbrains.compose.ui:ui-test-junit4-uikitarm64:1.4.3.". @Mohammed Did you get a solution for this? – David Aug 21 '23 at 13:06