cucumber / cucumber-android

Android support for Cucumber-JVM
MIT License
135 stars 62 forks source link

Compose rule not working on composables hosted in an activity #128

Closed alexymumo closed 2 months ago

alexymumo commented 7 months ago

👓 What did you see?

java.lang.IllegalStateException: Test not setup properly. Use a ComposeTestRule in your test to be able to interact with composables
at androidx.compose.ui.test.junit4.ComposeRootRegistry_androidKt.ensureComposeRootRegistryIsSetUp(ComposeRootRegistry.android.kt:254)
at androidx.compose.ui.test.junit4.ComposeRootRegistry_androidKt.waitForComposeRoots(ComposeRootRegistry.android.kt:261)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.waitForIdle(ComposeUiTest.android.kt:334)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment.access$waitForIdle(ComposeUiTest.android.kt:228)
at androidx.compose.ui.test.AndroidComposeUiTestEnvironment$AndroidTestOwner.getRoots(ComposeUiTest.android.kt:529)
at androidx.compose.ui.test.TestContext.getAllSemanticsNodes$ui_test_release(TestOwner.kt:85)
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNodes$ui_test_release(SemanticsNodeInteraction.kt:62)
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:128)
at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNode(SemanticsNodeInteraction.kt:79)
at androidx.compose.ui.test.TextActionsKt.getNodeAndFocus(TextActions.kt:108)
at androidx.compose.ui.test.TextActionsKt.getNodeAndFocus$default(TextActions.kt:105)
at androidx.compose.ui.test.TextActionsKt.performTextInput(TextActions.kt:42)

✅ What did you expect to see?

📦 Which tool/library version are you using?

🔬 How could we reproduce it

Steps to reproduce the behavior:

  1. Install '...' version '...'
  2. Create a file called '....'
  3. Run command '....'
  4. See error '....'

📚 Any additional context?


This text was originally generated from a template, then edited by hand. You can modify the template here.

prudhvir3ddy commented 6 months ago

@alexymumo You need to add the ComposeRuleHolder path inside the glue

@CucumberOptions(
    features = ["..."],
    glue = ["com.example.application.package_name"], // wherever your path is for the ComposRuleHolder
)
class CucumberAndroidTestRunner : CucumberAndroidJUnitRunner() {
lsuski commented 2 months ago

I assume it works now. I've enhance README on that topic