Slide 1

Slide 1 text

BY SERGIO SASTRE SCREENSHOT TESTING WHICH LIBRARY IS RIGHT FOR YOU? FOR ANDROID

Slide 2

Slide 2 text

WHAT Screenshot testing is @Gio_Sastre

Slide 3

Slide 3 text

Special type of UI tests take a screenshot of it, compare it to its reference we inflate a UI component, where and @Gio_Sastre

Slide 4

Slide 4 text

WORKS HOW Screenshot testing @Gio_Sastre

Slide 5

Slide 5 text

record AND verify @Gio_Sastre

Slide 6

Slide 6 text

write test CI @Gio_Sastre +

Slide 7

Slide 7 text

record CI @Gio_Sastre

Slide 8

Slide 8 text

= CI @Gio_Sastre

Slide 9

Slide 9 text

CI new PR + @Gio_Sastre

Slide 10

Slide 10 text

approve CI @Gio_Sastre

Slide 11

Slide 11 text

merge CI @Gio_Sastre

Slide 12

Slide 12 text

CI new PR verify @Gio_Sastre

Slide 13

Slide 13 text

CI new PR @Gio_Sastre

Slide 14

Slide 14 text

CI new PR @Gio_Sastre

Slide 15

Slide 15 text

CI new PR @Gio_Sastre

Slide 16

Slide 16 text

CI new PR @Gio_Sastre

Slide 17

Slide 17 text

EXIST? Which Screenshot testing libraries @Gio_Sastre

Slide 18

Slide 18 text

Screenshot testing libraries android-testify Paparazzi screenshot-tests 
 for-android Shot Dropshots Snappy Roborazzi @Gio_Sastre

Slide 19

Slide 19 text

on-device Screenshot testing libraries @Gio_Sastre

Slide 20

Slide 20 text

jvm layoutlib robolectric robolectric * Needs to be con f igured * Screenshot testing libraries @Gio_Sastre

Slide 21

Slide 21 text

in this talk jvm jvm on-device Screenshot testing libraries @Gio_Sastre on-device on-device

Slide 22

Slide 22 text

On-device Screenshot testing @Gio_Sastre

Slide 23

Slide 23 text

Dropshots Shot tolerance record & verify gradle managed devices test reports general value for all tests only from CLI @Gio_Sastre standard xml configuration problematic Windows support Kotlin gradle scripts ⚠ ⚠ super easy per test from CLI & AS very nice HTML with diffs not supported not supported + diffs android-testify easy per test CLI or AS Plugin supported YAML + diffs (experimental) max 1 snapshot per test

Slide 24

Slide 24 text

Dropshots Shot tolerance record & verify gradle managed devices test reports general value for all tests only from CLI @Gio_Sastre standard xml configuration problematic Windows support Kotlin gradle scripts ⚠ ⚠ super easy per test from CLI & AS very nice HTML with diffs not supported not supported + diffs android-testify easy per test CLI or AS Plugin supported YAML + diffs (experimental) max 1 snapshot per test

Slide 25

Slide 25 text

Jvm Screenshot testing @Gio_Sastre

Slide 26

Slide 26 text

Paparazzi Windows OS not supported Roborazzi Compose Multiplatform (as desktop) Dynamic Feature Modules not supported supported @Gio_Sastre supported 2 1 Due to Robolectric Native Graphics 2 Due to Robolectric supported 2 Bazel record & verify from CLI & AS only from CLI unofficial AS plugin supported 1 Via Skiko or not supported 3 3 not supported

Slide 27

Slide 27 text

Paparazzi Windows OS not supported Roborazzi Compose Multiplatform (as desktop) Dynamic Feature Modules not supported supported @Gio_Sastre supported 2 1 Due to Robolectric Native Graphics 2 Due to Robolectric supported 2 Bazel record & verify from CLI & AS only from CLI unofficial AS plugin supported 1 Via Skiko or not supported 3 3 not supported

Slide 28

Slide 28 text

Paparazzi complex animations (views) Side effects (compose) render elevation not supported Roborazzi different 
 API levels supported not supported not supported not fully supported not supported supported @Gio_Sastre supported2 1 2 1 Due to layoutlib 2 Due to Robolectric 2 supported supported2 2 Activities 
 & Fragments

Slide 29

Slide 29 text

Paparazzi complex animations (views) Side effects (compose) render elevation not supported Roborazzi different 
 API levels supported not supported not supported not fully supported not supported supported @Gio_Sastre supported2 1 2 1 Due to layoutlib 2 Due to Robolectric 2 supported supported2 2 Activities 
 & Fragments

Slide 30

Slide 30 text

DIFFERENT CONFIGS? SCREENSHOT TESTS under @Gio_Sastre

Slide 31

Slide 31 text

@Gio_Sastre Configuration matters 1 3 Locale UI Mode 2 Orientation 4 6 Custom themes Display Size 5 Font Size

Slide 32

Slide 32 text

Settings Display Font size > > Font Size @Gio_Sastre

Slide 33

Slide 33 text

@Gio_Sastre Font Size

Slide 34

Slide 34 text

Display Size Settings Display Display size > > @Gio_Sastre

Slide 35

Slide 35 text

Display Size @Gio_Sastre

Slide 36

Slide 36 text

Font Size vs. Display Size @Gio_Sastre

Slide 37

Slide 37 text

Font Size + Display Size @Gio_Sastre

Slide 38

Slide 38 text

MANY CONFIGS? HOW to screenshot test so @Gio_Sastre

Slide 39

Slide 39 text

Android Ui Testing Utils @Gio_Sastre 1 Screenshot Testing under different configurations https://github.com/sergio-sastre/AndroidUiTestingUtils 2 Cross-library screenshot testing

Slide 40

Slide 40 text

@Gio_Sastre possible Display size Font size + Locale UI Mode Orientation out of the box out of the box out of the box 1 via updateConfiguration() possible switch height & width 1 Activities under test must be open, otherwise still possible with AndroidUiTestingUtils out of the box Custom theme out of the box possible via updateConfiguration() out of the box out of the box out of the box robolectric based

Slide 41

Slide 41 text

JVM ? ON-DEVICE or @Gio_Sastre

Slide 42

Slide 42 text

complex animations (views) Side effects (compose) render elevation not supported different 
 API levels Activity & Fragment not supported not supported supported not fully supported not supported supported @Gio_Sastre supported2 1 2 1 Due to layoutlib 2 Due to Robolectric supported supported 2 robolectric based 2 2

Slide 43

Slide 43 text

supported supported supported supported supported complex animations (views) Side effects (compose) render elevation not supported different 
 API levels Activity & Fragment not supported not supported supported not fully supported not supported supported @Gio_Sastre supported2 1 2 1 Due to layoutlib 2 Due to Robolectric supported supported 2 robolectric based 2 2

Slide 44

Slide 44 text

@Gio_Sastre * Only possible with Paparazzi and Roborazzi On-device on-device vs. jvm Best fidelity Foldable support Special configuration (adb) Jvm Very fast Less flaky Accessibility services * (no issues with emulators)

Slide 45

Slide 45 text

Resources 1 @Gio_Sastre Github Repo https://github.com/sergio-sastre/Android-screenshot-testing-playground 2 Screenshot testing companion library https://github.com/sergio-sastre/AndroidUiTestingUtils

Slide 46

Slide 46 text

attention for your THANKS

Slide 47

Slide 47 text

GitHub @SergioSastre sergio-sastre-florez @sergio-sastre @Gio_Sastre Hashnode blogs Sergio Sastre Flórez Lead & Senior Android developer appdev.de Linkedin