Slide 34
Slide 34 text
PARAMETERIZED TEST CASES
@RunWith(TestParameterInjector::class)
class WeekCalendarParamScreenshotTest(
@TestParameter val uiMode: UiMode,
@TestParameter val fontSize: FontSize,
@TestParameter val todayIsSelectedDate: Boolean
) : ScreenshotTest {
...
@Test
fun weekCalendar_paramUiModeAndFontSizeAndSelectedDate() {
val todayDate = if (todayIsSelectedDate) testDate.minusDays(1) else testDate.minusDays(2)
val todayIsSelectedDateDescription = if (todayIsSelectedDate) "todayIsSelectedDate" else "todayIsNotSelectedDate"
val activityScenario = ActivityScenarioConfigurator.ForComposable()
.setUiMode(uiMode)
.setFontSize(fontSize)
.launchConfiguredActivity()
.onActivity {
it.setContent {
AppTheme {
WeekCalendar(...)
}
}
}
activityScenario.waitForActivity()
compareScreenshot(composeTestRule, "weekCalendar_${uiMode}_${fontSize}_${todayIsSelectedDateDescription}")
activityScenario.close()
}
}