dropbox / dropshots Goto Github PK
View Code? Open in Web Editor NEWEasy on-device screenshot testing for Android.
License: Apache License 2.0
Easy on-device screenshot testing for Android.
License: Apache License 2.0
Dropshots stores screenshots in my androidTest
directory even when my tests are present in androidTestDebug
. Is this intentional?
I made a basic test
@RunWith(Parameterized::class)
class NotificationActivitySmokeTests(val activityUnderTest: Class<out Activity>) {
@get:Rule
val sandboxRule = LoggedInFakeUserTestRule(activityUnderTest, true)
@get:Rule
val dropshots = com.dropbox.dropshots.Dropshots()
companion object {
@JvmStatic
@Parameterized.Parameters(name = "Notification Payload Batch: {index}")
fun activitesToSmokeTest(): List<Class<*>> =
listOf(
EmailNotificationsSettingsActivity::class.java,
PushNotificationsSettingsActivity::class.java,
SmsNotificationsSettingsActivity::class.java,
)
}
@Test
fun simpleTest() {
sandboxRule.getScenario().onActivity {
dropshots.assertSnapshot(it, "MatchesActivityScreenshot")
// assertThat(it).isInstanceOf(activityUnderTest)
}
}
}
I then ran ./gradlew myModule:CAT
I then got error
> Task :subsystem:tfa:notifications:sandboxes:app:pullDefaultDebugAndroidTestScreenshots FAILED
adb: error: failed to stat remote object '/storage/emulated/0/screenshots/com.twitter.sandbox.notifications.debug/.': No such file or directory
> Task :subsystem:tfa:notifications:sandboxes:app:clearDefaultDebugAndroidTestScreenshots FAILED
rm: /storage/emulated/0/screenshots/com.twitter.sandbox.notifications.debug: No such file or directory
I think its unexpected that tasks get added to cAT without some flag. Maybe have an explicit flag or don't fail if directory for deletion doesn't exist
Dropshots doesn't seem to be able to generate snapshots when tests are run on managed devices. This can be reproduced in the sample app. Any ideas what might be happening?
Hey,
there's a section in README about custom validation with objects like ResultValidator
, CountValidator
and ThresholdValidator
. But it seems that the Dropshots API is missing those elements in my project (ver 0.3.0
), could you please add a sample or small snippet on how to use that feature?
My gradle fu is not great but was wondering if it is possible to not have to apply android.library/android.app plugin before dropshots. Maybe there is an api that can check if it is on path rather than requiring ordering?
I wanted to try out this library, but as soon as I add plugin:
plugins {
id("com.android.application")
id 'org.jetbrains.kotlin.android'
id("com.dropbox.dropshots") version "0.2.0"
}
(plus mavenCentral()
in the repos, I already had it) the project can't sync gradle with an error:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> org/gradle/configurationcache/extensions/CharSequenceExtensionsKt
> KotlinJvmAndroidCompilation with name 'debug' not found.
Tried and can't make it run in three projects:
with the same result
Am I missing something?
Environment:
a) macbook with m1 pro chip, Android Studio Chipmunk | 2021.2.1 Patch 1
b) my colleague's macbook with intel
Thanks for new lightweight library, sounds like something that I'd need
Hi,
Thanks for creating this useful tool! I really appreciate the fact that assertSnapshot()
accepts a direct Bitmap as well, as that's more fitting for my use case than a View or Activity.
Issue
I had some issues getting this to work with my Android 10 (API 29) device. The runtime library is unable to write to the Downloads folder.
To my understanding, Android 10 is a bit of a special case in terms of scoped storage. It's the first version with scoped storage, but it doesn't have the direct file paths feature yet, introduced in Android 11, which re-enables the use of the Java File API.
Fix
So on Android 10, if an app wants to write to a media folder such as Downloads, it has 2 options:
requestLegacyExternalStorage
to true
and declare the WRITE_EXTERNAL_STORAGE
permission if it wants to use the Java File API.Accepting PRs?
I have the second option implemented in a local checkout of Dropshots and it's working well. Would you like me to create a pull request? I'd be happy to!
Making it clear to alpha testers before they waste an hour on this like I did :D
On top of the file name it would be great to be able to store the screenshots into folders.
I currently end up with hundreds of view screenshots and some names get truncated because they are too long. Having folders would allow more nested structure and would avoid prefix in file names
Happy to contribute if you agree with the feature
adb: error: failed to stat remote object '/storage/emulated/0/screenshots/com.google.samples.apps.nowinandroid.feature.topic/.': No such file or directory
Looking at the device file explorer, the screenshots are there but in a different directory:
/storage/emulated/0/screenshots/com.google.samples.apps.nowinandroid.feature.topic.test/MatchesActivityScreenshot.png
I'm still investigating this, but I bumped Dropshot from 0.1.1 to 0.2.0 and everything worked great. I was able to record and run.
Then I removed the WRITE_EXTERNAL_STORAGE permission from the module's manifest as it's no longer required and I started getting the error.
I added the permission again and I still see the same error. I tried cleaning, etc.
Consider checking the size and fail immediately. Since the comparison is made on device, a slow emulator can take a long time (I'm getting 37s per test).
We would lose the 3-way diff I assume.
This is more of a question - do i have to use cAT to get the record screenshot api? There's a use case I am dealing with where tests are running using the instrumentation api directly
The current plugin uses plugins.all
to get the library and application plugins once they're registered, but it should use pluginManager.withPlugin
instead, to avoid running over all plugins.
Does this library support for jetpack compose ui?
java.lang.AssertionError: "MatchesActivityScreenshot" failed to match reference image. 18 pixels differ (8.6805556E-4 %)
Output written to: /storage/emulated/0/Download/screenshots/com.google.samples.apps.nowinandroid.feature.topic.test/MatchesActivityScreenshot.png
However the screenshots
directory is empty, This might be a feature and the only bug is in the error message.
Using emulator API 30 and 28.
Me again :-) any reason we need api23, I was unable to use in a minapi 21 app.
> Task :subsystem:tfa:notifications:sandboxes:app:processDefaultDebugAndroidTestManifest FAILED
[androidx.test.espresso:espresso-core:3.2.0] /Users/mnakhimovich/.gradle/caches/transforms-3/baa638c28051cb16a7630d000c6f64db/transformed/espresso-core-3.2.0/AndroidManifest.xml Warning:
Package name 'androidx.test.espresso' used in: androidx.test.espresso:espresso-core:3.2.0, androidx.test.espresso:espresso-idling-resource:3.2.0.
/Users/mnakhimovich/workspace/twitter-android/build/projects/subsystem/tfa/notifications/sandboxes/app/intermediates/tmp/manifest/androidTest/default/debug/tempFile1ProcessTestManifest5391222334560463959.xml:5:5-74 Error:
uses-sdk:minSdkVersion 21 cannot be smaller than version 23 declared in library [com.dropbox.dropshots:dropshots:0.1.1] /Users/mnakhimovich/.gradle/caches/transforms-3/469c2a42c974d58408744a407cefc928/transformed/dropshots-0.1.1/AndroidManifest.xml as the library might be using APIs not available in 21
Suggestion: use a compatible library with a minSdk of at most 21,
or increase this project's minSdk version to at least 23,
or use tools:overrideLibrary="com.dropbox.dropshots" to force usage (may lead to runtime failures)
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.