Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./gradlew cAT failed in sample #68

Closed
hannesa2 opened this issue Nov 12, 2022 · 4 comments
Closed

./gradlew cAT failed in sample #68

hannesa2 opened this issue Nov 12, 2022 · 4 comments

Comments

@hannesa2
Copy link

You have no CI support, so I did a test run locally with ./gradlew cAT
But it fails with

> Task :android:connectedDebugAndroidTest
Starting 2 tests on API_30_Google_Api(AVD) - 11

io.github.usefulnes.testing.screenshot.sample.ScreenshotsSampleActivityTest > testScreenshotEntireActivityWithoutAccessibilityMetadata[API_30_Google_Api(AVD) - 11] FAILED 
        java.lang.RuntimeException: Failed to create the directory /sdcard/screenshots/io.github.usefulness.testing.screenshot.sample.test/screenshots-default for screenshots. Is your sdcard directory read-only?
        at com.facebook.testing.screenshot.internal.ScreenshotDirectories.getSdcardDir(ScreenshotDirectories.java:119)

io.github.usefulnes.testing.screenshot.sample.ScreenshotsSampleActivityTest > testScreenshotEntireActivity[API_30_Google_Api(AVD) - 11] FAILED 
        java.lang.RuntimeException: Failed to create the directory /sdcard/screenshots/io.github.usefulness.testing.screenshot.sample.test/screenshots-default for screenshots. Is your sdcard directory read-only?
        at com.facebook.testing.screenshot.internal.ScreenshotDirectories.getSdcardDir(ScreenshotDirectories.java:119)
Tests on API_30_Google_Api(AVD) - 11 failed: There was 2 failure(s).

> Task :android:connectedDebugAndroidTest FAILED
@mateuszkwiecinski
Copy link
Member

The library has exactly the same limitations as the original and it seems like you hit this: facebook/screenshot-tests-for-android#224 (comment)

You have to do the same as the CI pipeline does:

adb shell settings put global hidden_api_policy_p_apps 1
adb shell settings put global hidden_api_policy_pre_p_apps 1
adb shell settings put global hidden_api_policy 1

I hope this helps 🤞

@hannesa2
Copy link
Author

I didn't see that it's a fork. Anyway, thank you !

Btw, this looks very promising https://github.com/android/testing-samples/tree/main/ui/espresso/ScreenshotSample.
It's super fast, but I've to figure out, where the images are stored to be able to grab it from device

@hannesa2
Copy link
Author

Here they are ! It's so easy
image

@mateuszkwiecinski
Copy link
Member

Great! I'm happy this works for you as well 🎉

This is indeed a fork of https://github.com/facebook/screenshot-tests-for-android which I had to detach to be able to publish under my own credentials on mavencentral 🤷 The difference in features is this supports Gradle Configuration Cache (facebook/screenshot-tests-for-android#307)

if you're looking for some guidance, I recommend reading their documentation: https://facebook.github.io/screenshot-tests-for-android/#getting-started

However, if you're just considering to add screenshot testing, then I'd probably recommend using a different library: https://github.com/pedrovgs/Shot or even https://github.com/cashapp/paparazzi.
This, while being maintained, has a couple of design flaws that make it non-ideal for long term projects :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants