Bladeren bron

refactor e2e

Daniel Zlotin 7 jaren geleden
bovenliggende
commit
e29fcf4d36

+ 4
- 22
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ApplicationLifecycleTest.java Bestand weergeven

5
 import android.provider.Settings;
5
 import android.provider.Settings;
6
 import android.support.test.uiautomator.By;
6
 import android.support.test.uiautomator.By;
7
 
7
 
8
-import org.junit.FixMethodOrder;
9
 import org.junit.Test;
8
 import org.junit.Test;
10
-import org.junit.runners.MethodSorters;
11
 
9
 
12
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
10
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
13
 
11
 
14
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
15
 public class ApplicationLifecycleTest extends BaseTest {
12
 public class ApplicationLifecycleTest extends BaseTest {
16
 
13
 
17
 	@Test
14
 	@Test
18
-	public void _1_acceptsOverlayPermissions_ShowsWelcomeScreen() throws Exception {
19
-		launchTheApp();
20
-		assertMainShown();
21
-	}
22
-
23
-	@Test
24
-	public void _2_relaunchFromBackground() throws Exception {
25
-		launchTheApp();
26
-		assertMainShown();
15
+	public void relaunchFromBackground() throws Exception {
27
 		elementByText("PUSH").click();
16
 		elementByText("PUSH").click();
28
 		assertExists(By.text("Pushed Screen"));
17
 		assertExists(By.text("Pushed Screen"));
29
 
18
 
35
 	}
24
 	}
36
 
25
 
37
 	@Test
26
 	@Test
38
-	public void _3_relaunchAfterClose() throws Exception {
39
-		launchTheApp();
40
-		assertMainShown();
41
-
27
+	public void relaunchAfterClose() throws Exception {
42
 		elementByText("PUSH").click();
28
 		elementByText("PUSH").click();
43
 		assertExists(By.text("Pushed Screen"));
29
 		assertExists(By.text("Pushed Screen"));
44
 
30
 
49
 	}
35
 	}
50
 
36
 
51
 	@Test
37
 	@Test
52
-	public void _4_deviceOrientationDoesNotDestroyActivity() throws Exception {
53
-		launchTheApp();
54
-		assertMainShown();
38
+	public void deviceOrientationDoesNotDestroyActivity() throws Exception {
55
 		elementByText("PUSH").click();
39
 		elementByText("PUSH").click();
56
 		assertExists(By.text("Pushed Screen"));
40
 		assertExists(By.text("Pushed Screen"));
57
 
41
 
62
 	}
46
 	}
63
 
47
 
64
 	@Test
48
 	@Test
65
-	public void _5_relaunchAfterActivityKilledBySystem() throws Exception {
66
-		launchTheApp();
67
-		assertMainShown();
49
+	public void relaunchAfterActivityKilledBySystem() throws Exception {
68
 		elementByText("PUSH").click();
50
 		elementByText("PUSH").click();
69
 		assertExists(By.text("Pushed Screen"));
51
 		assertExists(By.text("Pushed Screen"));
70
 
52
 

+ 2
- 0
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/BaseTest.java Bestand weergeven

29
 	public void beforeEach() throws Exception {
29
 	public void beforeEach() throws Exception {
30
 		device().wakeUp();
30
 		device().wakeUp();
31
 		device().setOrientationNatural();
31
 		device().setOrientationNatural();
32
+		launchTheApp();
33
+		assertMainShown();
32
 	}
34
 	}
33
 
35
 
34
 	@After
36
 	@After

+ 5
- 1
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/EnvironmentTest.java Bestand weergeven

1
 package com.reactnativenavigation.e2e.androide2e;
1
 package com.reactnativenavigation.e2e.androide2e;
2
 
2
 
3
+import android.support.test.runner.AndroidJUnit4;
4
+
3
 import org.junit.Test;
5
 import org.junit.Test;
6
+import org.junit.runner.RunWith;
4
 
7
 
5
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
8
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
6
 import static org.assertj.core.api.Java6Assertions.assertThat;
9
 import static org.assertj.core.api.Java6Assertions.assertThat;
7
 
10
 
8
-public class EnvironmentTest extends BaseTest {
11
+@RunWith(AndroidJUnit4.class)
12
+public class EnvironmentTest {
9
 	@Test
13
 	@Test
10
 	public void instrumentationAndAssertJ() throws Exception {
14
 	public void instrumentationAndAssertJ() throws Exception {
11
 		assertThat(getInstrumentation().getTargetContext().getPackageName()).isEqualTo("com.reactnativenavigation.e2e.androide2e");
15
 		assertThat(getInstrumentation().getTargetContext().getPackageName()).isEqualTo("com.reactnativenavigation.e2e.androide2e");

+ 0
- 16
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ModalsTest.java Bestand weergeven

9
 
9
 
10
 	@Test
10
 	@Test
11
 	public void showModal() throws Exception {
11
 	public void showModal() throws Exception {
12
-		launchTheApp();
13
-		assertMainShown();
14
 		elementByText("SHOW MODAL").click();
12
 		elementByText("SHOW MODAL").click();
15
 		assertExists(By.text("Modal Screen"));
13
 		assertExists(By.text("Modal Screen"));
16
 	}
14
 	}
17
 
15
 
18
 	@Test
16
 	@Test
19
 	public void dismissModal() throws Exception {
17
 	public void dismissModal() throws Exception {
20
-		launchTheApp();
21
-		assertMainShown();
22
 		elementByText("SHOW MODAL").click();
18
 		elementByText("SHOW MODAL").click();
23
 		assertExists(By.text("Modal Screen"));
19
 		assertExists(By.text("Modal Screen"));
24
 
20
 
29
 
25
 
30
 	@Test
26
 	@Test
31
 	public void showMultipleModals() throws Exception {
27
 	public void showMultipleModals() throws Exception {
32
-		launchTheApp();
33
-		assertMainShown();
34
 		elementByText("SHOW MODAL").click();
28
 		elementByText("SHOW MODAL").click();
35
 		assertExists(By.text("Modal Stack Position: 1"));
29
 		assertExists(By.text("Modal Stack Position: 1"));
36
 
30
 
46
 
40
 
47
 	@Test
41
 	@Test
48
 	public void dismissUnknownContainerId() throws Exception {
42
 	public void dismissUnknownContainerId() throws Exception {
49
-		launchTheApp();
50
-		assertMainShown();
51
 		elementByText("SHOW MODAL").click();
43
 		elementByText("SHOW MODAL").click();
52
 		assertExists(By.text("Modal Stack Position: 1"));
44
 		assertExists(By.text("Modal Stack Position: 1"));
53
 
45
 
60
 
52
 
61
 	@Test
53
 	@Test
62
 	public void dismissModalByContainerIdWhenNotOnTop() throws Exception {
54
 	public void dismissModalByContainerIdWhenNotOnTop() throws Exception {
63
-		launchTheApp();
64
-		assertMainShown();
65
 		elementByText("SHOW MODAL").click();
55
 		elementByText("SHOW MODAL").click();
66
 		assertExists(By.text("Modal Stack Position: 1"));
56
 		assertExists(By.text("Modal Stack Position: 1"));
67
 
57
 
77
 
67
 
78
 	@Test
68
 	@Test
79
 	public void dismissAllPreviousModalsByIdWhenTheyAreBelowTopPresented() throws Exception {
69
 	public void dismissAllPreviousModalsByIdWhenTheyAreBelowTopPresented() throws Exception {
80
-		launchTheApp();
81
-		assertMainShown();
82
 		elementByText("SHOW MODAL").click();
70
 		elementByText("SHOW MODAL").click();
83
 		assertExists(By.text("Modal Stack Position: 1"));
71
 		assertExists(By.text("Modal Stack Position: 1"));
84
 		elementByText("SHOW MODAL").click();
72
 		elementByText("SHOW MODAL").click();
95
 
83
 
96
 	@Test
84
 	@Test
97
 	public void dismissSomeModalByIdDeepInTheStack() throws Exception {
85
 	public void dismissSomeModalByIdDeepInTheStack() throws Exception {
98
-		launchTheApp();
99
-		assertMainShown();
100
 		elementByText("SHOW MODAL").click();
86
 		elementByText("SHOW MODAL").click();
101
 		assertExists(By.text("Modal Stack Position: 1"));
87
 		assertExists(By.text("Modal Stack Position: 1"));
102
 		elementByText("SHOW MODAL").click();
88
 		elementByText("SHOW MODAL").click();
117
 	@Ignore
103
 	@Ignore
118
 	@Test
104
 	@Test
119
 	public void dismissAllModals() throws Exception {
105
 	public void dismissAllModals() throws Exception {
120
-		launchTheApp();
121
-		assertMainShown();
122
 		elementByText("SHOW MODAL").click();
106
 		elementByText("SHOW MODAL").click();
123
 		assertExists(By.text("Modal Stack Position: 1"));
107
 		assertExists(By.text("Modal Stack Position: 1"));
124
 		elementByText("SHOW MODAL").click();
108
 		elementByText("SHOW MODAL").click();

+ 0
- 6
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ReactEventsTest.java Bestand weergeven

9
 
9
 
10
 	@Test
10
 	@Test
11
 	public void pressingMenuOpensDevMenu() throws Exception {
11
 	public void pressingMenuOpensDevMenu() throws Exception {
12
-		launchTheApp();
13
-		assertMainShown();
14
 		device().pressKeyCode(KeyEvent.KEYCODE_MENU);
12
 		device().pressKeyCode(KeyEvent.KEYCODE_MENU);
15
 		assertExists(By.text("Debug JS Remotely"));
13
 		assertExists(By.text("Debug JS Remotely"));
16
 	}
14
 	}
17
 
15
 
18
 	@Test
16
 	@Test
19
 	public void pressingRTwiceInSuccessionReloadsReactNative() throws Exception {
17
 	public void pressingRTwiceInSuccessionReloadsReactNative() throws Exception {
20
-		launchTheApp();
21
-		assertMainShown();
22
 		elementByText("PUSH").click();
18
 		elementByText("PUSH").click();
23
 		assertExists(By.text("Pushed Screen"));
19
 		assertExists(By.text("Pushed Screen"));
24
 
20
 
30
 
26
 
31
 	@Test
27
 	@Test
32
 	public void pressingRTwiceWithDelayDoesNothing() throws Exception {
28
 	public void pressingRTwiceWithDelayDoesNothing() throws Exception {
33
-		launchTheApp();
34
-		assertMainShown();
35
 		elementByText("PUSH").click();
29
 		elementByText("PUSH").click();
36
 		assertExists(By.text("Pushed Screen"));
30
 		assertExists(By.text("Pushed Screen"));
37
 
31
 

+ 0
- 4
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenLifecycleTest.java Bestand weergeven

8
 
8
 
9
 	@Test
9
 	@Test
10
 	public void onStartOnStop() throws Exception {
10
 	public void onStartOnStop() throws Exception {
11
-		launchTheApp();
12
-		assertMainShown();
13
 		elementByText("PUSH LIFECYCLE SCREEN").click();
11
 		elementByText("PUSH LIFECYCLE SCREEN").click();
14
 		assertExists(By.text("onStart"));
12
 		assertExists(By.text("onStart"));
15
 		elementByText("PUSH TO TEST ONSTOP").click();
13
 		elementByText("PUSH TO TEST ONSTOP").click();
18
 
16
 
19
 	@Test
17
 	@Test
20
 	public void unmountIsCalledWhenPopped() throws Exception {
18
 	public void unmountIsCalledWhenPopped() throws Exception {
21
-		launchTheApp();
22
-		assertMainShown();
23
 		elementByText("PUSH LIFECYCLE SCREEN").click();
19
 		elementByText("PUSH LIFECYCLE SCREEN").click();
24
 		assertExists(By.text("onStart"));
20
 		assertExists(By.text("onStart"));
25
 
21
 

+ 0
- 8
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenStackTest.java Bestand weergeven

8
 
8
 
9
 	@Test
9
 	@Test
10
 	public void pushAndPopScreen() throws Exception {
10
 	public void pushAndPopScreen() throws Exception {
11
-		launchTheApp();
12
-		assertMainShown();
13
 		elementByText("PUSH").click();
11
 		elementByText("PUSH").click();
14
 		assertExists(By.text("Pushed Screen"));
12
 		assertExists(By.text("Pushed Screen"));
15
 		elementByText("POP").click();
13
 		elementByText("POP").click();
18
 
16
 
19
 	@Test
17
 	@Test
20
 	public void popScreenDeepInTheStack() throws Exception {
18
 	public void popScreenDeepInTheStack() throws Exception {
21
-		launchTheApp();
22
-		assertMainShown();
23
 		elementByText("PUSH").click();
19
 		elementByText("PUSH").click();
24
 		assertExists(By.text("Pushed Screen"));
20
 		assertExists(By.text("Pushed Screen"));
25
 		assertExists(By.text("Stack Position: 1"));
21
 		assertExists(By.text("Stack Position: 1"));
33
 
29
 
34
 	@Test
30
 	@Test
35
 	public void popToId() throws Exception {
31
 	public void popToId() throws Exception {
36
-		launchTheApp();
37
-		assertMainShown();
38
 		elementByText("PUSH").click();
32
 		elementByText("PUSH").click();
39
 		elementByText("PUSH").click();
33
 		elementByText("PUSH").click();
40
 		elementByText("PUSH").click();
34
 		elementByText("PUSH").click();
45
 
39
 
46
 	@Test
40
 	@Test
47
 	public void popToRoot() throws Exception {
41
 	public void popToRoot() throws Exception {
48
-		launchTheApp();
49
-		assertMainShown();
50
 		elementByText("PUSH").click();
42
 		elementByText("PUSH").click();
51
 		elementByText("PUSH").click();
43
 		elementByText("PUSH").click();
52
 		elementByText("PUSH").click();
44
 		elementByText("PUSH").click();

+ 0
- 2
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/ScreenStyleStaticTest.java Bestand weergeven

8
 
8
 
9
 	@Test
9
 	@Test
10
 	public void declareNavigationStyleOnContainerComponent() throws Exception {
10
 	public void declareNavigationStyleOnContainerComponent() throws Exception {
11
-		launchTheApp();
12
-		assertMainShown();
13
 		elementByText("PUSH OPTIONS SCREEN").click();
11
 		elementByText("PUSH OPTIONS SCREEN").click();
14
 		assertExists(By.text("Static Title"));
12
 		assertExists(By.text("Static Title"));
15
 	}
13
 	}

+ 0
- 5
AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e/TopLevelApiTest.java Bestand weergeven

2
 
2
 
3
 import android.support.test.uiautomator.By;
3
 import android.support.test.uiautomator.By;
4
 
4
 
5
-import org.junit.Ignore;
6
 import org.junit.Test;
5
 import org.junit.Test;
7
 
6
 
8
 public class TopLevelApiTest extends BaseTest {
7
 public class TopLevelApiTest extends BaseTest {
9
 
8
 
10
 	@Test
9
 	@Test
11
 	public void switchToTabBasedApp_PassPropsFunction() throws Exception {
10
 	public void switchToTabBasedApp_PassPropsFunction() throws Exception {
12
-		launchTheApp();
13
-		assertMainShown();
14
 		elementByText("SWITCH TO TAB BASED APP").click();
11
 		elementByText("SWITCH TO TAB BASED APP").click();
15
 		assertExists(By.text("This is tab 1"));
12
 		assertExists(By.text("This is tab 1"));
16
 		assertExists(By.text("Hello from a function!"));
13
 		assertExists(By.text("Hello from a function!"));
18
 
15
 
19
 	@Test
16
 	@Test
20
 	public void switchToTabsWithSideMenu() throws Exception {
17
 	public void switchToTabsWithSideMenu() throws Exception {
21
-		launchTheApp();
22
-		assertMainShown();
23
 		elementByText("SWITCH TO APP WITH SIDE MENUS").click();
18
 		elementByText("SWITCH TO APP WITH SIDE MENUS").click();
24
 		assertExists(By.textStartsWith("This is a side menu center screen tab 1"));
19
 		assertExists(By.textStartsWith("This is a side menu center screen tab 1"));
25
 		swipeOpenLeftSideMenu();
20
 		swipeOpenLeftSideMenu();