-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun-tests
More file actions
executable file
·66 lines (55 loc) · 2.01 KB
/
run-tests
File metadata and controls
executable file
·66 lines (55 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
# --- Java Detection ---
if [ -z "$JAVA_HOME" ]; then
STUDIO_BIN=$(which android-studio 2>/dev/null || which studio 2>/dev/null)
if [ -n "$STUDIO_BIN" ]; then
STUDIO_PATH=$(readlink -f "$STUDIO_BIN")
STUDIO_DIR=$(dirname "$(dirname "$STUDIO_PATH")")
if [ -d "$STUDIO_DIR/jbr" ]; then
export JAVA_HOME="$STUDIO_DIR/jbr"
fi
fi
fi
# If still not found, check if common location for this environment exists
if [ -z "$JAVA_HOME" ] && [ -d "/opt/android-studio/jbr" ]; then
export JAVA_HOME="/opt/android-studio/jbr"
fi
if [ -n "$JAVA_HOME" ]; then
echo "☕ Using JAVA_HOME: $JAVA_HOME"
else
echo "⚠️ JAVA_HOME not set and could not be detected automatically. Default 'java' will be used."
fi
# --- Run Tests ---
FAILED=0
echo "🧪 Running all unit tests (local)..."
./gradlew test || FAILED=1
echo ""
echo "📱 Checking for connected devices for instrumented tests..."
# Check for any device or emulator
ADB_DEVICES=$(adb devices | grep -v "List" | grep "device$" | awk '{print $1}')
if [ -n "$ADB_DEVICES" ]; then
echo "🚀 Devices detected: $ADB_DEVICES"
echo "🧪 Running instrumented tests (on device)..."
./gradlew connectedDebugAndroidTest || FAILED=1
else
echo "⚠️ No connected devices found. Skipping instrumented tests."
echo "To run instrumented tests, start an emulator or connect a real device."
fi
if [ $FAILED -eq 0 ]; then
echo ""
echo "✅ All tests completed successfully!"
else
echo ""
echo "❌ Some tests failed."
fi
echo ""
echo "📊 Reports available at:"
echo "------------------------------------------------------------"
echo "🖥️ Local Unit Tests: file://$(pwd)/quickRouteMap/build/reports/tests/testDebugUnitTest/index.html"
if [ -n "$ADB_DEVICES" ]; then
echo "📱 Instrumented Tests: file://$(pwd)/quickRouteMap/build/reports/androidTests/connected/debug/index.html"
fi
echo "------------------------------------------------------------"
if [ $FAILED -ne 0 ]; then
exit 1
fi