-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun-tests.sh
executable file
·65 lines (54 loc) · 1.6 KB
/
run-tests.sh
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
#!/bin/bash
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Create output directory for reports
OUTPUT_DIR="test-reports"
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"
# First arg is total runs
if [ "$1" != "" ]; then
total_runs=$1
else
total_runs=10
fi
# Second arg is the gradle task to run
if [ "$2" != "" ]; then
gradle_task=$2
else
gradle_task="testDebugUnitTest"
fi
success_count=0
failure_count=0
echo "Running test $total_runs times with gradle task $gradle_task..."
echo "------------------------"
start_time=$(date +%s)
for ((i=1; i<=total_runs; i++)); do
echo -n "Run #$i: "
# Run the specific test with correct flags
touch "$OUTPUT_DIR/test-run-$i.txt"
./gradlew $gradle_task --rerun-tasks --daemon > "$OUTPUT_DIR/test-run-$i.txt" 2>&1
if [ $? -eq 0 ]; then
((success_count++))
echo -e "${GREEN}PASSED${NC}"
else
((failure_count++))
echo -e "${RED}FAILED${NC}"
# Print the output of the test run
echo "Output of test run $i:"
cat "$OUTPUT_DIR/test-run-$i.txt"
# Copy the HTML report with run number
cp -R "./android/build/reports/tests/" "$OUTPUT_DIR/failure-run-$i/"
fi
done
echo "------------------------"
echo "Execution time: $(($(date +%s) - start_time)) seconds"
echo "Results:"
echo "Total runs: $total_runs"
echo -e "Successes: ${GREEN}$success_count${NC}"
echo -e "Failures: ${RED}$failure_count${NC}"
echo "Failure rate: $(( (failure_count * 100) / total_runs ))%"
if [ $failure_count -gt 0 ]; then
echo "Failure reports saved in $OUTPUT_DIR/"
fi