Created
August 13, 2014 16:35
-
-
Save shikajiro/5f26c021fc00e7b22992 to your computer and use it in GitHub Desktop.
Androidでのテストで色々悩んだ結果robotiumになった件 ref: http://qiita.com/shikajiro@github/items/d28bf5eb4c9268f81131
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
public void testSayHello() { | |
//このclickで画面遷移すると仮定する。 | |
onView(withId(R.id.greet_button)) | |
.perform(click()); | |
//遷移後の画面に"Hello Steve!"が表示されるが、このassertはOKだったりNGだったりする。 | |
onView(withText("Hello Steve!")) | |
.check(matches(isDisplayed())); | |
} |
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
buildTypes { | |
debug{ | |
applicationIdSuffix ".debug" | |
} | |
} |
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
//クリックすると非同期処理が始まる | |
clickOn(view); | |
//ちょっとまってくれる(願望) | |
Robolectric.runUiThreadTasksIncludingDelayedTasks() | |
//非同期処理終了後、ダイアログが表示されるはずなので取得する。 | |
AlertDialog alert = ShadowAlertDialog.getLatestAlertDialog(); | |
//だが、この時点でalertはnull | |
assertNotNull(alert); |
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
public void testTerm(){ | |
//viewのクリック処理 | |
solo.clickOnView(mActivity.findViewById(R.id.termView)); | |
//新規に開いたActivityと一致するか | |
solo.assertCurrentActivity("利用規約画面", TermWebActivity_.class); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment