Last active
October 24, 2022 14:25
-
-
Save stoefln/df0d6b0d05d618b9aed8298b5c1b6aa3 to your computer and use it in GitHub Desktop.
DropShotsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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