Considerations:
- We're considering removing the instrumented tests that simply assert that something exist. Local screenshot tests cover more and are much more reliable
Uncertain:
- The project contributors might not find the new workflow intuitive.
- Git doesn't generally like big binary files.
- Screenshots can't be commited into forks (you have to create your PR in the fork first)
Example PR: https://github.com/android/nowinandroid/pull/918/files
A fully functional Android app built entirely with Kotlin and Jetpack Compose - Adds dark screenshot tests and fixes background colors in ForYou by JoseAlcerreca · Pull Request #918 · android/nowinandroid
We added screenshot tests to the Now In Android app!
Some decisions:
- We're using Roborazzi, which uses Robolectric to take the screenshots.
- Screenshots are captured and compared on CI to avoid subtle platform differences. Diff threshold is set to 0.
- We decided to skip git LFS: Old files can't be flushed easily and Github didn't show images correctly.
From Accompanist v0.28.0 you can try out the new Test Harness library!
You can use it in Compose tests to resize a composable so it always fits the device, change locales, toggle dark mode, and more!
📑Check out the docs: https://google.github.io/accompanist/testharness/
Congrats
@alex_vanyo!
@alexvanyo
created a test harness for Compose that lets you fit any Composable into any device, among other things. It's similar to @Preview but for tests.
And we're bringing it to Accompanist. Check it out and give us feedback! https://github.com/google/accompanist/pull/1392