Browse Source

refactor e2e

Daniel Zlotin 7 years ago
parent
commit
e29fcf4d36

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

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

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

@@ -29,6 +29,8 @@ public abstract class BaseTest {
29 29
 	public void beforeEach() throws Exception {
30 30
 		device().wakeUp();
31 31
 		device().setOrientationNatural();
32
+		launchTheApp();
33
+		assertMainShown();
32 34
 	}
33 35
 
34 36
 	@After

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

@@ -1,11 +1,15 @@
1 1
 package com.reactnativenavigation.e2e.androide2e;
2 2
 
3
+import android.support.test.runner.AndroidJUnit4;
4
+
3 5
 import org.junit.Test;
6
+import org.junit.runner.RunWith;
4 7
 
5 8
 import static android.support.test.InstrumentationRegistry.getInstrumentation;
6 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 13
 	@Test
10 14
 	public void instrumentationAndAssertJ() throws Exception {
11 15
 		assertThat(getInstrumentation().getTargetContext().getPackageName()).isEqualTo("com.reactnativenavigation.e2e.androide2e");

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

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

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

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

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

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

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

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

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

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

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

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