From 1829d54b852205718b2b70eb63fe1c296fe58754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Fri, 22 Mar 2024 11:09:56 +0000 Subject: [PATCH] Adds a new test to design system Change-Id: I2a40de18400c053d9dff772bceda474a376a8c48 --- .github/workflows/Build.yaml | 3 ++- .../core/designsystem/ButtonScreenshotTests.kt | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 44b014817..db326c380 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -194,7 +194,8 @@ jobs: - name: Run local tests (including Roborazzi) for the combined coverage report (only API 30) if: matrix.api-level == 30 - run: ./gradlew testDemoDebugUnitTest # Add Prod if we ever add JVM tests for prod + # There is no need to verify Roborazzi tests to generate coverage. + run: ./gradlew testDemoDebugUnitTest -Proborazzi.test.verify=false # Add Prod if we ever add JVM tests for prod # Add `createProdDebugUnitTestCoverageReport` if we ever add JVM tests for prod - name: Generate coverage reports for Debug variants (only API 30) diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/ButtonScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/ButtonScreenshotTests.kt index 2f6ab5370..d514f9a67 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/ButtonScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/ButtonScreenshotTests.kt @@ -23,6 +23,7 @@ import androidx.compose.material3.Text import androidx.compose.ui.test.junit4.createAndroidComposeRule import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaButton import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaOutlinedButton +import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTextButton import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.testing.util.captureMultiTheme import dagger.hilt.android.testing.HiltTestApplication @@ -77,4 +78,21 @@ class ButtonScreenshotTests { } } } + + @Test + fun niaTextButton_coverageTest() { + composeTestRule.captureMultiTheme( + name = "TextButton", + overrideFileName = "TextButton", + shouldCompareAndroidTheme = false, + ) { description -> + Surface { + NiaTextButton( + onClick = {}, + text = { Text("Coverage test") }, + leadingIcon = { Icon(imageVector = NiaIcons.Add, contentDescription = null) }, + ) + } + } + } }