Jose Alcérreca

485 Followers
38 Following
15 Posts
Android Developer Relations Engineer @ Google
AndroidX, Gradle and Metalava - Android Developers Backstage

YouTube

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

Adds dark screenshot tests and fixes background colors in ForYou by JoseAlcerreca · Pull Request #918 · android/nowinandroid

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

GitHub

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.

🧪 Here's a JUnit TestRule that keeps your composable content through activity recreation. It's only needed if you want to test recreation/config changes using an empty activity.
https://gist.github.com/JoseAlcerreca/2fa4ed3c8e6759f8c62eb9e022534103
Feedback welcome!
ActivityLifecycleTestRule.kt

GitHub Gist: instantly share code, notes, and snippets.

Gist
@codewiththeitalians @ppvi Join us in 15 minutes to see how you can add a test harness for your instrumented tests!
Performance review time at Goog. If you see a manager, hug them.

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!

Guide - Accompanist

A group of libraries to help write Jetpack Compose apps.

Remember when this was acceptable?

@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

[Test Harness] Add test harness library by alexvanyo · Pull Request #1392 · google/accompanist

Adds a new testing library, testharness for testing Compose layouts.

GitHub
In architecture-templates, I'd like to set up
Renovate bot
so it updates Kotlin and the Compose compiler in an independent PR. If anyone want to take a stab at it, let me know 😅 https://github.com/android/architecture-templates/issues/34
[Renovate] Offer Kotlin and Compose compiler updates independently · Issue #34 · android/architecture-templates

Almost every Renovate PR is broken because it tries to update Kotlin, but we can't bump it until the Compose compiler is ready. Example: dff4200 Renovate has a "groups" feature that s...

GitHub