Created
December 31, 2010 15:45
-
-
Save palfrey/761092 to your computer and use it in GitHub Desktop.
Robolectric test
This file contains hidden or 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
| @RunWith(RobolectricTestRunner.class) | |
| public class MyActivityTest { | |
| private Activity activity; | |
| private Button pressMeButton; | |
| private TextView results; | |
| @Before | |
| public void setUp() throws Exception { | |
| activity = new MyActivity(); | |
| activity.onCreate(null); | |
| pressMeButton = (Button) activity.findViewById(R.id.press_me_button); | |
| results = (TextView) activity.findViewById(R.id.results_text_view); | |
| } | |
| @Test | |
| public void shouldUpdateResultsWhenButtonIsClicked() throws Exception { | |
| pressMeButton.performClick(); | |
| String resultsText = results.getText().toString(); | |
| assertEquals("Testing Android Rocks!", resultsText); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment