implement an Espresso test
This commit is contained in:
parent
cc856b3d05
commit
ca53937aef
|
@ -10,6 +10,8 @@ android {
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -25,5 +27,10 @@ dependencies {
|
||||||
compile 'com.jakewharton:butterknife:7.0.1'
|
compile 'com.jakewharton:butterknife:7.0.1'
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
testCompile "org.robolectric:robolectric:3.0"
|
testCompile 'org.robolectric:robolectric:3.0'
|
||||||
|
|
||||||
|
androidTestCompile 'com.android.support:support-annotations:23.1.1'
|
||||||
|
androidTestCompile 'com.android.support.test:runner:0.4.1'
|
||||||
|
androidTestCompile 'com.android.support.test:rules:0.4.1'
|
||||||
|
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,8 @@ package calculator.simplemobiletools.com.simple_calculator;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.test.ApplicationTestCase;
|
import android.test.ApplicationTestCase;
|
||||||
|
|
||||||
/**
|
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
|
||||||
*/
|
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||||
public ApplicationTest() {
|
public ApplicationTest() {
|
||||||
super(Application.class);
|
super(Application.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package calculator.simplemobiletools.com.simple_calculator;
|
||||||
|
|
||||||
|
import android.support.test.rule.ActivityTestRule;
|
||||||
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static android.support.test.espresso.Espresso.onView;
|
||||||
|
import static android.support.test.espresso.action.ViewActions.click;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class MainActivityTest {
|
||||||
|
@Rule
|
||||||
|
public ActivityTestRule<MainActivity> mActivityRule =
|
||||||
|
new ActivityTestRule<>(MainActivity.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addDigitTest() {
|
||||||
|
onView(withId(R.id.btn_5)).perform(click());
|
||||||
|
onView(withId(R.id.result)).check(matches(withText("5")));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue