-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainActivityTest.java
51 lines (41 loc) · 1.61 KB
/
MainActivityTest.java
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
42
43
44
45
46
47
48
49
50
51
package sg.edu.np.mad.madpractical2;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.core.app.ActivityScenario;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityScenarioRule<MainActivity> activityRule =
new ActivityScenarioRule<>(MainActivity.class);
@Before
public void setUp() throws Exception {
activityRule.getScenario();
}
@Test
public void changeText_sameActivity() {
// Type text and then press the button
onView(withId(R.id.btnFollow)).perform(click());
onView(withId(R.id.btnFollow)).perform(click());
onView(withId(R.id.btnFollow)).perform(click());
onView(withId(R.id.btnFollow)).perform(click());
onView(withId(R.id.btnFollow)).perform(click());
onView(withId(R.id.btnFollow)).check(matches(isDisplayed()));
}
@After
public void tearDown() throws Exception {
}
}