android-testify icon indicating copy to clipboard operation
android-testify copied to clipboard

Support Compose Preview testing

Open DanielJette opened this issue 7 months ago • 4 comments

Objective

Support Android's Compose Preview testing as a alternative to the emulator-based screenshot testing tool. This will expand the usefulness of Testify and allow for additional testing methodologies.

Method

  1. Enhance the Testify Intellij Plugin to provide shortcuts to facilitate the use of Compose Preview testing
  2. Provide a Compose Preview extension library to wrap common patterns and workflows

References

  • https://developer.android.com/studio/preview/compose-screenshot-testing
  • https://developer.android.com/develop/ui/compose/tooling/previews

DanielJette avatar May 19 '25 15:05 DanielJette

Pattern:

Theme is required

"The code you've provided already wraps your MovieDetails composable in FlixTheme. This is good practice."

DanielJette avatar May 19 '25 15:05 DanielJette

Bug:

Resources$NotFoundException

The android helper function dimensionResource() does not work by default in Preview contexts.

https://issuetracker.google.com/issues/379710081

  • This appears to be a problem unique to the screenshotTest configuration. I reproduced the same composable Preview in the main project body and it previewed correctly, without issue.

DanielJette avatar May 19 '25 15:05 DanielJette

Bug:

Missing clases

"The following classes could not be found: - androidx.compose.ui.tooling.ComposeViewAdapter (Add ui-tooling library dependency to the project, Fix Build Path, Edit File, Create Class)"

Solution:

uiTooling = "1.7.1"
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "uiTooling" }

DanielJette avatar May 19 '25 15:05 DanielJette

Bug:

imagePromise does not load anything

DanielJette avatar May 19 '25 16:05 DanielJette