-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun-tests-android.sh
More file actions
executable file
·66 lines (56 loc) · 2.01 KB
/
Copy pathrun-tests-android.sh
File metadata and controls
executable file
·66 lines (56 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
cd "$(dirname "$0")"
source test_start_helpers.sh
function get_full_path {
echo "$( cd "$(dirname "$1")"; echo "$(pwd)/$(basename "$1")" )"
}
# Setup Appium
app_path='../example-unity-project/example-app.apk'
export APPIUM_APP_ACTIVITY="Unity"
export APPIUM_APPFILE=${APPIUM_APPFILE:="$(get_full_path "$app_path")"}
export APPIUM_DEVICE="Local Device"
export APPIUM_PLATFORM="android"
# Run adb once so API level can be read without the "daemon not running"-message
adb devices
APILEVEL=$(adb shell getprop ro.build.version.sdk)
APILEVEL="${APILEVEL//[$'\t\r\n']}"
export APILEVEL
echo "API level is: ${APILEVEL}"
export MOCHA_BIN='mocha'
TESTDROID=${TESTDROID:=0}
if [ "$TESTDROID" -eq "1" ]; then
# We cannot install system wide, need to have relative path to mocha-binary
npm install mocha
echo "mocha executable: '$(file node_modules/.bin/mocha)'"
MOCHA_BIN='./node_modules/.bin/mocha'
fi
if [ -z "$APILEVEL" ]; then
echo "ERROR: Could not read android API-Level."
echo "Exiting with failure before starting test!"
exit 1
fi
if [ "$APILEVEL" -gt "18" ]; then
echo "Setting APPIUM_AUTOMATION=android"
export APPIUM_AUTOMATION="Android"
export TEST="unity-ads.js"
else
echo "Setting APPIUM_AUTOMATION=selendroid"
export APPIUM_AUTOMATION="Selendroid"
export TEST="unity-ads_android_legacy.js"
fi
# Pipe logcat to file
echo "Starting logging"
adb logcat -v time -s "$APPIUM_APP_ACTIVITY" > "logcat.log" &
adbPid=$!
if [ "$TESTDROID" -eq "1" ]; then
npm install [email protected] colors underscore chai-as-promised wd path mkdirp yiewd tail mocha-junit-reporter mocha 2>&1
./node_modules/.bin/mocha example_tests.js --reporter mocha-junit-reporter --reporter-options mochaFile=./TEST-all.xml 2>&1
export scriptExitStatus=$?
else
npm install [email protected] colors underscore chai-as-promised wd path mkdirp yiewd tail mocha-junit-reporter mocha
./node_modules/.bin/mocha example_tests.js
export scriptExitStatus=$?
fi
echo "Test stopped with status '$scriptExitStatus'"
kill $adbPid
exit $scriptExitStatus