Browse Source

added test framework - robolectric

Daniel Zlotin 8 years ago
parent
commit
aa64e3973f

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

@@ -1,3 +1,23 @@
1
+buildscript {
2
+    repositories {
3
+        jcenter()
4
+    }
5
+    dependencies {
6
+        classpath 'com.android.tools.build:gradle:2.1.2'
7
+    }
8
+}
9
+
10
+allprojects {
11
+    repositories {
12
+        mavenLocal()
13
+        jcenter()
14
+        maven {
15
+            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
16
+            url "$projectDir/../../node_modules/react-native/android"
17
+        }
18
+    }
19
+}
20
+
1 21
 apply plugin: 'com.android.library'
2 22
 
3 23
 android {
@@ -24,6 +44,9 @@ android {
24 44
             minifyEnabled false
25 45
         }
26 46
     }
47
+    lintOptions {
48
+        abortOnError false
49
+    }
27 50
 }
28 51
 
29 52
 repositories {
@@ -33,10 +56,21 @@ repositories {
33 56
     }
34 57
 }
35 58
 
59
+allprojects { p ->
60
+    p.tasks.whenTaskAdded { task ->
61
+        if (task.name.toLowerCase().contains('lint')) {
62
+            task.enabled = false;
63
+        }
64
+    }
65
+}
66
+
36 67
 dependencies {
37 68
     compile fileTree(dir: "libs", include: ["*.jar"])
38 69
     compile "com.aurelhubert:ahbottomnavigation:1.2.3"
39 70
     compile "com.android.support:appcompat-v7:23.0.1"
40 71
     compile 'com.android.support:design:23.1.1'
41 72
     compile "com.facebook.react:react-native:+"  // From node_modules
73
+
74
+    testCompile 'junit:junit:4.12'
75
+    testCompile "org.robolectric:robolectric:3.1.1"
42 76
 }

+ 19
- 0
android/app/src/test/java/com/reactnativenavigation/FirstTest.java View File

@@ -0,0 +1,19 @@
1
+package com.reactnativenavigation;
2
+
3
+import org.junit.Test;
4
+import org.junit.runner.RunWith;
5
+import org.robolectric.RobolectricTestRunner;
6
+
7
+import static org.hamcrest.Matchers.is;
8
+import static org.junit.Assert.assertThat;
9
+
10
+@RunWith(RobolectricTestRunner.class)
11
+public class FirstTest {
12
+
13
+    @Test
14
+    public void woohoo() {
15
+        assertThat(1+2, is(3));
16
+    }
17
+
18
+
19
+}