https://kotlinlang.org logo
#test
Title
# test
c

chanjungskim

03/06/2023, 4:08 AM
I am trying to write ui test with compose. And I get
Instrumentation run failed due to Process crashed.
error. Is there any solution?
here's my code. in
androidTest
.
Copy code
@HiltAndroidTest
class VitaminScreenComposeTest {
    @get:Rule(order = 0)
    val hiltRule = HiltAndroidRule(this)

    @get:Rule(order = 1)
    val composeTestRule = createComposeRule()

    @Test
    fun entryQuestionLayout(){
        val entryQuestionJson = loadFileText(this, "/surveyQuestion.json")
        val entryQuestion = Gson().fromJsonToArrayList(entryQuestionJson, Question::class.java)[0]

        composeTestRule.setContent {
            VitaminScreen(false, entryQuestion, {},{},{})
        }

        composeTestRule.onNodeWithText("scientific").assertIsDisplayed()
        composeTestRule.onNodeWithText("professional").assertIsDisplayed()
    }
}
7 Views