Browse Source

trying to run espresso tests but needs overlay permissions

Daniel Zlotin 7 years ago
parent
commit
fd50579715

+ 0
- 3
android/app/build.gradle View File

@@ -61,7 +61,4 @@ dependencies {
61 61
     testCompile 'org.robolectric:robolectric:3.2.2'
62 62
     testCompile 'org.assertj:assertj-core:2.5.0'
63 63
     testCompile 'org.mockito:mockito-core:2.7.5'
64
-
65
-    // native e2e
66
-    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
67 64
 }

+ 3
- 3
android/app/src/main/AndroidManifest.xml View File

@@ -2,10 +2,10 @@
2 2
     package="com.reactnativenavigation">
3 3
 
4 4
     <application>
5
-        <activity android:name=".controllers.NavigationActivity"/>
5
+        <activity android:name=".controllers.NavigationActivity" />
6 6
 
7
-        <!--<activity
7
+        <activity
8 8
             android:name="com.facebook.react.devsupport.DevSettingsActivity"
9
-            android:exported="false" />-->
9
+            android:exported="false" />
10 10
     </application>
11 11
 </manifest>

+ 0
- 12
android/app/src/test/java/com/reactnativenavigation/ApplicationTest.java View File

@@ -1,12 +0,0 @@
1
-package com.reactnativenavigation;
2
-
3
-import org.junit.Test;
4
-
5
-import static org.assertj.core.api.Java6Assertions.assertThat;
6
-
7
-public class ApplicationTest {
8
-    @Test
9
-    public void startingActivity() {
10
-        assertThat(1+2).isNotZero();
11
-    }
12
-}

+ 18
- 0
playground/android/app/build.gradle View File

@@ -11,6 +11,8 @@ android {
11 11
         targetSdkVersion 25
12 12
         versionCode 1
13 13
         versionName "1.0"
14
+
15
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 16
     }
15 17
 }
16 18
 
@@ -20,4 +22,20 @@ dependencies {
20 22
     compile 'com.android.support:design:25.1.1'
21 23
     compile "com.android.support:appcompat-v7:25.1.1"
22 24
     compile project(':react-native-navigation')
25
+
26
+    // native e2e
27
+    androidTestCompile 'com.android.support:support-annotations:25.1.1'
28
+    androidTestCompile 'com.android.support.test:runner:0.5'
29
+    androidTestCompile 'com.android.support.test:rules:0.5'
30
+    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
31
+        exclude module: 'jsr305'
32
+    }
33
+    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
34
+        exclude module: 'support-annotations'
35
+        exclude module: 'support-v4'
36
+        exclude module: 'support-v13'
37
+        exclude module: 'recyclerview-v7'
38
+        exclude module: 'design'
39
+        exclude module: 'jsr305'
40
+    }
23 41
 }

+ 25
- 0
playground/android/app/src/androidTest/java/com/reactnativenavigation/playground/ApplicationTest.java View File

@@ -0,0 +1,25 @@
1
+package com.reactnativenavigation.playground;
2
+
3
+import android.support.test.espresso.action.ViewActions;
4
+import android.support.test.rule.ActivityTestRule;
5
+import android.support.test.runner.AndroidJUnit4;
6
+
7
+import org.junit.Rule;
8
+import org.junit.Test;
9
+import org.junit.runner.RunWith;
10
+
11
+import static android.support.test.espresso.Espresso.onView;
12
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
13
+
14
+@RunWith(AndroidJUnit4.class)
15
+public class ApplicationTest {
16
+
17
+    @Rule
18
+    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class);
19
+
20
+    @Test
21
+    public void startsTheApp() {
22
+        
23
+        onView(withText("Playground")).perform(ViewActions.click());
24
+    }
25
+}

+ 3
- 2
playground/package.json View File

@@ -7,8 +7,9 @@
7 7
     "start": "adb reverse tcp:8081 tcp:8081; watchman watch-del-all; react-native start",
8 8
     "xcode": "open ios/playground.xcodeproj",
9 9
     "android": "cd android && ./gradlew installDebug",
10
-    "xcodeunit": "node ./scripts/xCodeUnit.js",
11
-    "e2e": "node ./scripts/e2e.ios.js"
10
+    "xcodeunit": "node ./scripts/unit.ios.js",
11
+    "e2e-android": "node ./scripts/e2e.android.js",
12
+    "e2e-ios": "node ./scripts/e2e.ios.js"
12 13
   },
13 14
   "//": "use react-native-navigation: 2.x.x --> we are manually installing it from a script for quicker workflow. Along with detox and shell-utils",
14 15
   "dependencies": {},

+ 20
- 0
playground/scripts/e2e.android.js View File

@@ -0,0 +1,20 @@
1
+const _ = require('lodash');
2
+const shellUtils = require('shell-utils');
3
+const fs = require('fs');
4
+
5
+const release = _.includes(process.argv, 'release');
6
+
7
+function e2e() { //eslint-disable-line
8
+  try {
9
+    shellUtils.exec.execSync(`echo 'travis_fold:start:android-espresso'`);
10
+    shellUtils.exec.execSync(`cd android && ./gradlew connectedDebugAndroidTest`);
11
+  } finally {
12
+    shellUtils.exec.execSync(`echo 'travis_fold:end:android-espresso'`);
13
+  }
14
+}
15
+
16
+function run() {
17
+  e2e();
18
+}
19
+
20
+run();

playground/scripts/xCodeUnit.js → playground/scripts/unit.ios.js View File


+ 1
- 1
scripts/test.ios.js View File

@@ -4,7 +4,7 @@ function run() {
4 4
   process.chdir('./playground');
5 5
   exec.execSync(`yarn run quickinstall`);
6 6
   exec.execSync(`yarn run xcodeunit`);
7
-  exec.execSync(`yarn run e2e release`);
7
+  exec.execSync(`yarn run e2e-ios release`);
8 8
   process.chdir('../');
9 9
 }
10 10