Support Compose Preview testing
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
- Enhance the Testify Intellij Plugin to provide shortcuts to facilitate the use of Compose Preview testing
- 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
Pattern:
Theme is required
"The code you've provided already wraps your MovieDetails composable in FlixTheme. This is good practice."
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.
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" }
Bug:
imagePromise does not load anything