From 3e87d922051aa256973e0918ae596abe75e0a01c Mon Sep 17 00:00:00 2001 From: Victor Garcia Date: Fri, 21 Jun 2024 13:09:10 +0200 Subject: [PATCH] Add Testing folder in docs --- docs/getting-started.md | 6 ++++ docs/testing/_category_.yml | 2 ++ docs/testing/recomposition.md | 21 +++++++++++++ docs/testing/screenshot-testing.md | 50 ++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 docs/testing/_category_.yml create mode 100644 docs/testing/recomposition.md create mode 100644 docs/testing/screenshot-testing.md diff --git a/docs/getting-started.md b/docs/getting-started.md index c9633dcf8..803c7703c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,3 +1,9 @@ +--- +id: getting-started +title: Getting started +sidebar_position: 1 +--- + # DHIS2 Mobile UI > **@dhis2/dhis2-mobile-ui** is diff --git a/docs/testing/_category_.yml b/docs/testing/_category_.yml new file mode 100644 index 000000000..4137e9b42 --- /dev/null +++ b/docs/testing/_category_.yml @@ -0,0 +1,2 @@ +position: 2 +label: 'Testing' diff --git a/docs/testing/recomposition.md b/docs/testing/recomposition.md new file mode 100644 index 000000000..ca9a5953d --- /dev/null +++ b/docs/testing/recomposition.md @@ -0,0 +1,21 @@ +--- +id: recomposition +title: Recomposition +sidebar_position: 1 +--- + +# Recomposition + +The Compose Compiler plugin can generate reports / metrics around certain compose-specific concepts +that can be useful to understand what is happening with some of your compose code at a fine-grained +level. +You can read more about +it [here](https://github.com/androidx/androidx/blob/androidx-main/compose/compiler/design/compiler-metrics.md). + +To generate the reports / metrics, run the following Gradle command + +```shell +./gradlew assembleDebug -PenableComposeCompilerReports=true +``` + +This would generate the output at `/build/compose_metrics`. \ No newline at end of file diff --git a/docs/testing/screenshot-testing.md b/docs/testing/screenshot-testing.md new file mode 100644 index 000000000..b914c886a --- /dev/null +++ b/docs/testing/screenshot-testing.md @@ -0,0 +1,50 @@ +--- +id: screenshot-testing +title: Screenshot testing +sidebar_position: 2 +--- + +# Screenshot Testing + +We are using [Paparazzi](https://cashapp.github.io/paparazzi/) for screenshot testing. + +## Screenshot testing + +```kotlin +class InputChipSnapshotTest { + + @get:Rule + val paparazzi = paparazzi() + + @Test + fun launchChip() { + paparazzi.snapshot { + ColumnComponentContainer { + InputChip(label = "Label", selected = false, badge = "3") + InputChip(label = "Label", selected = true, badge = "3") + } + } + } +} +``` + +## Running tests + +`./gradlew designsystem:testDebugUnitTest` + +Runs tests and generates an HTML report at `/build/reports/paparazzi/` showing all test runs +and snapshots. + +## Saving golden images to repo + +`./gradlew designsystem:recordPaparazziDebug` + +Saves snapshots as golden values to a predefined source-controlled location (defaults to +`/src/test/snapshots`). + +## Verifying + +`./gradlew designsystem:verifyPaparazziDebug` + +Runs tests and verifies against previously-recorded golden values. Failures generate diffs at +`/build/paparazzi/failures`. \ No newline at end of file