Skip to content

Commit f03364c

Browse files
author
Ali Abdelfattah
authored
Merge pull request #401 from Instabug/e2e/android-setup
e2e/android detox setup
2 parents baf8a73 + 4dd26fe commit f03364c

File tree

5 files changed

+116
-2
lines changed

5 files changed

+116
-2
lines changed

.circleci/config.yml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ jobs:
158158
name: Install Detox Utils
159159
command: brew tap wix/brew && brew install applesimutils
160160
- run:
161-
name: Install node_modules
161+
name: Install Node Packages
162162
command: yarn
163163
- run:
164164
name: Fetch CocoaPods Specs
@@ -173,6 +173,65 @@ jobs:
173173
name: Detox - Run E2E Tests
174174
command: detox test --configuration ios.sim.release --cleanup
175175

176+
e2e_android:
177+
macos:
178+
xcode: "10.2.0"
179+
working_directory: ~/project/InstabugSample
180+
steps:
181+
- checkout:
182+
path: ~/project
183+
- run:
184+
name: Install Android SDK
185+
command: |
186+
HOMEBREW_NO_AUTO_UPDATE=1 brew tap homebrew/cask
187+
HOMEBREW_NO_AUTO_UPDATE=1 brew cask install android-sdk
188+
- run:
189+
name: Accept Android SDK Licenses
190+
command: (yes | sdkmanager --licenses) || true
191+
- run:
192+
name: Setup Android Environment Variables
193+
command: |
194+
echo 'export JAVA_HOME=`/usr/libexec/java_home -v 1.8`' >> $BASH_ENV
195+
echo 'export ANDROID_HOME=/usr/local/share/android-sdk' >> $BASH_ENV
196+
echo 'export ANDROID_SDK_ROOT=/usr/local/share/android-sdk' >> $BASH_ENV
197+
echo 'export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> $BASH_ENV
198+
- run:
199+
name: SDK Manager - Download Emulator Image
200+
command: (yes | sdkmanager "platform-tools" "platforms;android-27" "extras;intel;Hardware_Accelerated_Execution_Manager" "build-tools;27.0.3" "system-images;android-27;google_apis;x86" "emulator" --verbose) || true
201+
- run:
202+
name: AVD Manager - Setup Emulator
203+
command: avdmanager create avd -n Nexus_6P_API_27 -k "system-images;android-27;google_apis;x86" -g google_apis -d "Nexus 6P"
204+
- run:
205+
name: Run Emulator in background
206+
command: /usr/local/share/android-sdk/emulator/emulator @Nexus_6P_API_27 -noaudio -no-boot-anim -no-window
207+
background: true
208+
- run:
209+
name: Install Node Packages
210+
command: sudo yarn
211+
- run:
212+
name: Generate Android Keystore
213+
command: cd android/app && keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=AA, OU=AA, O=AA, L=AA, S=AA, C=EG"
214+
- run:
215+
name: Make gradlew Executable
216+
command: cd android && chmod +x ./gradlew
217+
- run:
218+
name: Download Android Dependencies
219+
command: cd android && ./gradlew androidDependencies
220+
- run:
221+
name: Install Detox CLI
222+
command: sudo npm install -g detox-cli
223+
- run:
224+
name: Detox - Build Release App
225+
command: |
226+
sudo chmod -R 777 /Users/distiller/project/InstabugSample/node_modules/instabug-reactnative
227+
detox build --configuration android.emu.release
228+
- run:
229+
name: Detox - Run E2E Tests
230+
command: |
231+
sudo chmod -R 777 /Users/distiller/Library/Detox
232+
detox test --configuration android.emu.release --cleanup
233+
234+
176235
publish:
177236
macos:
178237
xcode: "10.1.0"
@@ -192,12 +251,16 @@ workflows:
192251
- test_sample
193252
- test_android
194253
- test_ios
254+
- e2e_ios
255+
- e2e_android
195256
- hold:
196257
requires:
197258
- test_module
198259
- test_sample
199260
- test_android
200261
- test_ios
262+
- e2e_ios
263+
- e2e_android
201264
type: approval
202265
filters:
203266
branches:

InstabugSample/android/app/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ android {
119119
targetSdkVersion rootProject.ext.targetSdkVersion
120120
versionCode 1
121121
versionName "1.0"
122+
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
123+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
122124
}
123125
splits {
124126
abi {
@@ -173,6 +175,11 @@ dependencies {
173175
} else {
174176
implementation 'org.webkit:android-jsc:+'
175177
}
178+
179+
// Detox
180+
implementation "androidx.annotation:annotation:1.1.0"
181+
androidTestImplementation('com.wix:detox:+') { transitive = true }
182+
androidTestImplementation 'junit:junit:4.12'
176183
}
177184

178185
// Run this once to be able to run the application with BUCK
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.instabugsample;
2+
3+
import com.wix.detox.Detox;
4+
5+
import org.junit.Rule;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
9+
import androidx.test.ext.junit.runners.AndroidJUnit4;
10+
import androidx.test.filters.LargeTest;
11+
import androidx.test.rule.ActivityTestRule;
12+
13+
@RunWith(AndroidJUnit4.class)
14+
@LargeTest
15+
public class DetoxTest {
16+
17+
@Rule
18+
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19+
20+
@Test
21+
public void runDetoxTests() {
22+
Detox.runTests(mActivityRule);
23+
}
24+
}

InstabugSample/android/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
buildscript {
44
ext {
55
buildToolsVersion = "28.0.3"
6-
minSdkVersion = 16
6+
minSdkVersion = 18
77
compileSdkVersion = 28
88
targetSdkVersion = 28
99
supportLibVersion = "28.0.0"
10+
kotlinVersion = '1.3.10'
1011
}
1112
repositories {
1213
google()
1314
jcenter()
1415
}
1516
dependencies {
1617
classpath("com.android.tools.build:gradle:3.4.1")
18+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
1719

1820
// NOTE: Do not place your application dependencies here; they belong
1921
// in the individual module build.gradle files
@@ -31,6 +33,10 @@ allprojects {
3133
// Android JSC is installed from npm
3234
url("$rootDir/../node_modules/jsc-android/dist")
3335
}
36+
maven {
37+
// All of Detox' artifacts are provided via the npm module
38+
url "$rootDir/../node_modules/detox/Detox-android"
39+
}
3440

3541
google()
3642
jcenter()

InstabugSample/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@
4444
"build": "xcodebuild -workspace ios/InstabugSample.xcworkspace -scheme InstabugSample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
4545
"type": "ios.simulator",
4646
"name": "iPhone X"
47+
},
48+
"android.emu.debug": {
49+
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
50+
"build":
51+
"cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
52+
"type": "android.emulator",
53+
"name": "Pixel_3_API_28"
54+
},
55+
"android.emu.release": {
56+
"binaryPath": "android/app/build/outputs/apk/release/app-release.apk",
57+
"build":
58+
"cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..",
59+
"type": "android.emulator",
60+
"name": "Nexus_6P_API_27"
4761
}
4862
}
4963
}

0 commit comments

Comments
 (0)