-
Notifications
You must be signed in to change notification settings - Fork 249
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
Demo App: Screenshot testing #1158
Conversation
"Add UI automation framework"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed please sync and remove reference directory.
also should the html files be checked in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
I added my 5 cents, but let's not block this PR. Feel free to add TODOs instead of doing actual changes.
@@ -206,6 +215,7 @@ object Dependencies { | |||
const val mockitoKotlin = "3.2.0" | |||
const val mockitoInline = "4.0.0" | |||
const val robolectric = "4.5.1" | |||
// const val facebookScreenshotPlugin = "0.14.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicates l:209
} | ||
|
||
object Espresso { | ||
const val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}" | ||
} | ||
|
||
// const val screenshotPlugin = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated above
@RunWith(AndroidJUnit4::class) | ||
class ScreenshotTest { | ||
|
||
@get:Rule var activityTestRule = ActivityTestRule(MainActivity::class.java, false, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActivityTestRule
is deprecated. Please use ActivityScenario
instead.
https://developer.android.com/reference/androidx/test/core/app/ActivityScenario
This would change the way we would do snapActivity
:
activityScenario.onActivity { activity ->
Screenshot.snapActivity(activity).record()
}
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> | ||
<style | ||
name="AppTheme" | ||
parent="Theme.MaterialComponents.Light.DarkActionBar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you switch to Light theme from DayNight one on purpose?
val view = activityTestRule.activity.findViewById<TextView>(R.id.search_src_text) | ||
snapActivity(activity).setName("Registered Patient List").record() | ||
snap(view).setName("sample_view_test").record() | ||
Thread.sleep(5000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet most of those timeouts are not necessary.
Espresso tools (IdlingResources) could be used instead.
Can you please remove all the HTML files that are included??? |
@epicadk FYI this is the PR I mentioned earlier |
import androidx.test.runner.AndroidJUnitRunner | ||
import com.facebook.testing.screenshot.ScreenshotRunner | ||
|
||
class ScreenShotTestRunner : AndroidJUnitRunner() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only required when we are using a custom test runner right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
The html files seem to contain the test output. I reckon we can safely leave them out. |
@vvikramraj + @kevinmost will you be able to investigate further and see if we can get this PR to be merged in some shape or form? |
as @aditya-07 pointed out, the plugin doesn't support API level 30+, so I'm not sure theres a lot we can do. |
alternative: https://github.com/cashapp/paparazzi |
thanks @epicadk - we'll close this PR for now. also worth noting that you can also take screenshots in espresso tests. https://github.com/android/testing-samples |
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).
Fixes #[issue number]
Description
Clear and concise code change description.
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Choose one: (Bug fix | Feature | Documentation | Testing | Code health | Builds | Releases | Other)
Screenshots (if applicable)
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project./gradlew check
and./gradlew connectedCheck
to test my changes locally