Skip to content

Instantly share code, notes, and snippets.

@stoefln
Last active October 24, 2022 14:25
Show Gist options
  • Save stoefln/df0d6b0d05d618b9aed8298b5c1b6aa3 to your computer and use it in GitHub Desktop.
Save stoefln/df0d6b0d05d618b9aed8298b5c1b6aa3 to your computer and use it in GitHub Desktop.
DropShotsTest.kt
class MyTest {
@get:Rule
val activityScenarioRule = ActivityScenarioRule(TestActivity::class.java)
@get:Rule
val dropshots = Dropshots()
@Before
fun setup() {
// Setup your activity however you like
activityScenarioRule.scenario.onActivity {
it.supportFragmentManager.beginTransaction()
.add(android.R.id.content, ScreenshotTestFragment())
.commitNow()
}
}
@Test
fun testMatchesActivityScreenshot() {
activityScenarioRule.scenario.onActivity {
// Assert activity snapshots
dropshots.assertSnapshot(it, "MatchesActivityScreenshot")
}
}
@Test
fun testMatchesViewScreenshot() {
activityScenarioRule.scenario.onActivity {
// or assert view snapshots.
dropshots.assertSnapshot(
it.findViewById<View>(android.R.id.content),
name = "MatchesViewScreenshot"
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment