-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathEspressoTest.java
More file actions
41 lines (38 loc) · 1.17 KB
/
Copy pathEspressoTest.java
File metadata and controls
41 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.example.testing.testingexample;
import androidx.test.InstrumentationRegistry;
/**
* 不推荐
*/
//public class EspressoTest extends ActivityInstrumentationTestCase2<MainActivity> {
//
// private static final String STRING_TO_BE_TYPED = "peter";
// private MainActivity activity;
//
// public EspressoTest() {
// super(MainActivity.class);
// }
//
// @Override public void setUp() throws Exception {
// super.setUp();
// /**
// * 必须调用这两行代码
// */
// injectInstrumentation(InstrumentationRegistry.getInstrumentation());
// activity = getActivity();
// }
//
// /**
// * 方法名必须以test开头.尽量不要继承,请使用JUnit 4 style,
// * 这样写会多写代码,并且会出错.
// * 比如此例,输入太慢了,程序就执行了.
// */
// public void testSayHello() {
// onView(withId(R.id.editText)).perform(typeText(STRING_TO_BE_TYPED),
// closeSoftKeyboard()); //line 1
//
// onView(withText("Say hello!")).perform(click()); //line 2
//
// String expectedText = "Hello, " + STRING_TO_BE_TYPED + "!";
// onView(withId(R.id.textView)).check(matches(withText(expectedText))); //line 3
// }
//}