From b46cdeed78b1b243d6e10de8ce6f0e914cef7656 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Fri, 24 Feb 2023 18:30:01 +0900 Subject: [PATCH] #9 - Create a simple UI test --- .../example/compose/rally/TopAppBarTest.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 TestingCodelab/app/src/androidTest/java/com/example/compose/rally/TopAppBarTest.kt diff --git a/TestingCodelab/app/src/androidTest/java/com/example/compose/rally/TopAppBarTest.kt b/TestingCodelab/app/src/androidTest/java/com/example/compose/rally/TopAppBarTest.kt new file mode 100644 index 0000000..f10ca91 --- /dev/null +++ b/TestingCodelab/app/src/androidTest/java/com/example/compose/rally/TopAppBarTest.kt @@ -0,0 +1,30 @@ +package com.example.compose.rally + +import androidx.compose.ui.test.assertIsSelected +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithContentDescription +import com.example.compose.rally.ui.components.RallyTopAppBar +import org.junit.Rule +import org.junit.Test + +class TopAppBarTest { + + @get:Rule + val composeTestRule = createComposeRule() + + @Test + fun rallyTopAppBarTest() { + val allScreens = RallyScreen.values().toList() + composeTestRule.setContent { + RallyTopAppBar( + allScreens = allScreens, + onTabSelected = {}, + currentScreen = RallyScreen.Accounts + ) + } + + composeTestRule + .onNodeWithContentDescription(RallyScreen.Accounts.name) + .assertIsSelected() + } +} \ No newline at end of file