Android の自動テスト フレームワークを調べていたところ、Espresso にたどり着きました。信頼性の高いテスト、最小限のボイラープレート コード、パフォーマンスの向上など、私が望んでいたすべてが揃っているように見えました。
Espresso のデモを行っている GTAC 2013 のプレゼンテーションを見て、テストの実行速度を見て非常に興奮しました。ただし、実際にいくつかのテストを実装したので、標準の Android テスト フレームワークを使用した場合よりもパフォーマンスが向上したとしても、あまり気付かないと言わざるを得ません。「公式の」ベンチマークは行っていませんが、Espresso が標準の Android テスト フレームワークを吹き飛ばしたことは理解しています。
私がテストしているプロジェクトは、developer.android.com のチュートリアルで説明されているものです。私が書いているテストは非常に単純です。
@Test
public void test_sendButton_shouldInitiallyBeDisabled() {
onView(withId(R.id.button_send)).check(matches(not(ViewMatchers.isEnabled())));
}
@Test
public void test_sendButton_shouldBeEnabledAfterEnteringText() {
String enteredText = "This is my message!";
// Type Text
onView(withId(R.id.edit_message)).perform(ViewActions.typeText(enteredText));
// Validate the Result
onView(withId(R.id.button_send)).check(matches(ViewMatchers.isEnabled()));
}
@Test
public void test_enteringTextAndPressingSendButton_shouldDisplayEnteredText() {
String enteredText = "This is my message!";
// Type Text
onView(withId(R.id.edit_message)).perform(ViewActions.typeText(enteredText));
// Click Button
onView(withId(R.id.button_send)).perform(click());
// Validate the Results
onView(withId(R.id.display_message)).check(ViewAssertions.matches(ViewMatchers.withText(enteredText)));
}
Espresso Web サイトのすべての指示に従いましたが、実行構成で GoogleInstrumentationTestRunner を使用していることに特に細心の注意を払いました。
それで、私は何が欠けていますか?簡単なことを見逃したのですか?それとも、パフォーマンスが大幅に向上したという私の前提は完全に間違っていますか?