Challenge 2: A Compose UI Test — Solution class CounterScreenTest { @get:Rule val composeTestRule = createComposeRule() @Test fun clickingIncrementTwiceShowsCountTwo() { composeTestRule.setContent { CounterScreen() } composeTestRule.onNodeWithText("Increment").performClick() composeTestRule.onNodeWithText("Increment").performClick() composeTestRule.onNodeWithText("Count: 2").assertIsDisplayed() } } Notes: - @get:Rule is a use-site target (Kotlin Intermediate Chapter 6) — required here because JUnit's @Rule annotation must apply to the Kotlin property's underlying field/getter specifically for JUnit's test runner to recognize it correctly. - composeTestRule.setContent { CounterScreen() } is the Compose-testing equivalent of what setContent { } does in a real MainActivity (Course 2, Chapter 1) — it renders the composable into a test environment without needing an actual running app. - performClick() is called twice, each time re-locating the button via onNodeWithText("Increment") — since the button's own text doesn't change between clicks (only the Count text does), the same lookup works for both taps. - assertIsDisplayed() confirms the node exists AND is visible on screen — a node existing in the composition tree but not actually shown would fail this specific assertion.