Created
April 27, 2018 18:42
-
-
Save fmedlin/879821a00f927964e8d11a998278312a to your computer and use it in GitHub Desktop.
Robolectric Examples
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
/** | |
* The dialog returned by ShadowDialog.getLatestDialog() does not expose much for testing. | |
* However, getting an AlertDialog shadow can help. | |
*/ | |
@RunWith(RobolectricTestRunner::class) | |
class WebLoginActivityTest { | |
private lateinit var activity: SomeActivity | |
@Before | |
fun setup() { | |
activity = Robolectric.setupActivity(WebLoginActivity::class.java) | |
} | |
@Test | |
fun itDialogsLoginErrors() { | |
activity.dialogError("Some Title", "Some message that we display") | |
val dialog = ShadowDialog.getLatestDialog() as AlertDialog | |
shadowOf(dialog).apply { | |
title shouldEqual "Some Title" | |
message shouldEqual "Some message that we display" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment