Last active
August 29, 2015 14:17
-
-
Save up1/41ef122435874a7ec872 to your computer and use it in GitHub Desktop.
Demo espresso
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
dependencies { | |
... | |
compile 'com.android.support:support-annotations:21.0.3' | |
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0' | |
androidTestCompile 'com.android.support.test:testing-support-lib:0.1' | |
} |
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
android { | |
.... | |
defaultConfig { | |
.... | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
} | |
} |
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
onView(withId(R.id.myText)).check(matches(withText(expected))); |
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
onView(withId(R.id.convert)).perform(click()); |
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
package com.example; | |
import android.test.ActivityInstrumentationTestCase2; | |
import android.test.suitebuilder.annotation.LargeTest; | |
import com.example.somkiat.calculate.MyActivity; | |
import com.example.somkiat.calculate.R; | |
import static android.support.test.espresso.Espresso.onView; | |
import static android.support.test.espresso.action.ViewActions.click; | |
import static android.support.test.espresso.action.ViewActions.typeText; | |
import static android.support.test.espresso.assertion.ViewAssertions.matches; | |
import static android.support.test.espresso.matcher.ViewMatchers.withId; | |
import static android.support.test.espresso.matcher.ViewMatchers.withText; | |
@LargeTest | |
public class MyGradeCalculate extends ActivityInstrumentationTestCase2<MyActivity> { | |
public MyGradeCalculate() { | |
super(MyActivity.class); | |
} | |
@Override | |
public void setUp() throws Exception { | |
super.setUp(); | |
getActivity(); | |
} | |
public void testShowGradeDWhenScoreIs50() { | |
onView(withId(R.id.score)).perform(typeText(String.valueOf(50))); | |
onView(withId(R.id.convert)).perform(click()); | |
onView(withId(R.id.result)).check(matches(withText("Your grade = D"))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment