sergio-sastre / android-screenshot-testing-playground Goto Github PK
View Code? Open in Web Editor NEWA sample repo to introduce screenshot testing in Android with different libraries
License: MIT License
A sample repo to introduce screenshot testing in Android with different libraries
License: MIT License
Android-Testify works with GMD (Gradle Managed Devices) but requires the screenshots to be copied into androidTest/assets before verifying them.
The idea is to create a simple gradle task that does that automatically
def devices = project.hasProperty("devices") ? project.devices : "pixel3api30"
tasks.register('copyScreenshots', Copy) {
from "build/outputs/managed_device_android_test_additional_output/debug/${devices}/images"
into "src/androidTest/assets"
}
and then run it like this before verifying
./gradlew :lazycolumnscreen:android-testify:copyScreenshots -Pdevices=pixel3api30
When I execute Android-Testify Tests with, e.g.
./gradlew :recyclerviewscreen:android-testify:screenshotRecord -PscreenshotAnnotation=com.example.road.to.effective.snapshot.testing.testannotations.ViewHolderTest
The test fails with
dev.testify.output.TestStorageNotFoundException:
* TestStorage service not found.
* Please ensure that `testInstrumentationRunnerArguments useTestStorageService: "true"` is added to your build.gradle.
It seems that the problem is in the gradle plugin configuration:
testify {
...
useTestStorage = true
}
if we remove it or set it to false, it works
So we should only set it to true when executing Android-Testify Screenshot Tests with Gradle Managed Devices
Now possible with https://github.com/robolectric/robolectric/releases/tag/robolectric-4.10-alpha-1
Robolectric 4.10 adds support for native Android graphics. It is currently disabled by default and can be enabled using @GraphicsMode(NATIVE). When native graphics is enabled, interactions with Android graphics classes use real native Android graphics code and are much higher fidelity.
Shot requires some adjustments to run on AGP 7.x.x (configure applicationId)
Additionally, shot supports windows since 5.12.2 and FontSizeTestRule has a new version
I thought it was not possible to run Android-Testify tests with Gradle Managed devices only for a group of tests (e.g. tests with a given annotation)
It turns out, I was wrong, and it accepts the standard instrumentation arguments
The code was adapted from a personal project and had therefore a lot of commented code and leftovers.
This task should clean up and structure the code a bit
Specially when running on the CI, it is cumbersome to do that manually.
We can use TestButler for that, and add also an option not to use testButler -> animations won't be disabled automatically
Add also documentation on how to do it
Right now everything is in one module.
ideally we should create one module for each action e.g.
Every button in the main screen opens an activity -> module
I tried to run the shot test for both lazycolumn
and recyclerview
screen but there is no generated screenshot for both the record and the verification.
I checked the screenshot folder and it is empty too.
The report also shows 0 tests executed.
The test shows up and report from androidTest
directory confirm that.
How to solve this or did i miss something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.