Files
honeyDueKMP/iosApp/run_ui_tests.sh
Trey T 00e9ed0a96 Add localization strings and iOS test infrastructure
- Expand Localizable.xcstrings with 426 new localization entries
- Add xctestplan files (CI, Cleanup, Parallel, Seed) for structured test runs
- Add run_ui_tests.sh script for UI test execution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 20:32:09 -05:00

175 lines
6.2 KiB
Bash
Executable File

#!/bin/bash
# run_ui_tests.sh — Three-phase UI test runner with parallel middle phase
#
# Usage:
# ./run_ui_tests.sh # Default: iPhone 17 Pro, 4 workers
# ./run_ui_tests.sh "iPhone Air" 3 # Custom device and worker count
# ./run_ui_tests.sh --skip-seed # Skip seeding (already done)
# ./run_ui_tests.sh --skip-cleanup # Skip cleanup at end
# ./run_ui_tests.sh --only-parallel # Only run parallel phase
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT="$SCRIPT_DIR/honeyDue.xcodeproj"
SCHEME="HoneyDueUITests"
DESTINATION="platform=iOS Simulator,name=iPhone 17 Pro"
WORKERS=4
SKIP_SEED=false
SKIP_CLEANUP=false
ONLY_PARALLEL=false
# Parse flags (positional args for device/workers, flags for skip options)
POSITIONAL_ARGS=()
for arg in "$@"; do
case $arg in
--skip-seed) SKIP_SEED=true ;;
--skip-cleanup) SKIP_CLEANUP=true ;;
--only-parallel) ONLY_PARALLEL=true; SKIP_SEED=true; SKIP_CLEANUP=true ;;
*) POSITIONAL_ARGS+=("$arg") ;;
esac
done
if [ ${#POSITIONAL_ARGS[@]} -ge 1 ]; then
DESTINATION="platform=iOS Simulator,name=${POSITIONAL_ARGS[0]}"
fi
if [ ${#POSITIONAL_ARGS[@]} -ge 2 ]; then
WORKERS="${POSITIONAL_ARGS[1]}"
fi
RESULTS_DIR="$SCRIPT_DIR/build/test-results"
DERIVED_DATA="$SCRIPT_DIR/build/DerivedData"
mkdir -p "$RESULTS_DIR" "$DERIVED_DATA"
BOLD='\033[1m'
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
RESET='\033[0m'
phase_header() {
echo ""
echo -e "${BOLD}════════════════════════════════════════════════════${RESET}"
echo -e "${BOLD} $1${RESET}"
echo -e "${BOLD}════════════════════════════════════════════════════${RESET}"
echo ""
}
# Seed tests — must run first, sequentially
SEED_TESTS=(
"-only-testing:HoneyDueUITests/AAA_SeedTests"
)
# All parallelizable test classes
PARALLEL_TESTS=(
"-only-testing:HoneyDueUITests/AuthCriticalPathTests"
"-only-testing:HoneyDueUITests/NavigationCriticalPathTests"
"-only-testing:HoneyDueUITests/SmokeTests"
"-only-testing:HoneyDueUITests/SimpleLoginTest"
"-only-testing:HoneyDueUITests/Suite0_OnboardingTests"
"-only-testing:HoneyDueUITests/Suite1_RegistrationTests"
"-only-testing:HoneyDueUITests/Suite2_AuthenticationTests"
"-only-testing:HoneyDueUITests/Suite3_ResidenceTests"
"-only-testing:HoneyDueUITests/Suite4_ComprehensiveResidenceTests"
"-only-testing:HoneyDueUITests/Suite5_TaskTests"
"-only-testing:HoneyDueUITests/Suite6_ComprehensiveTaskTests"
"-only-testing:HoneyDueUITests/Suite7_ContractorTests"
"-only-testing:HoneyDueUITests/Suite8_DocumentWarrantyTests"
"-only-testing:HoneyDueUITests/Suite9_IntegrationE2ETests"
"-only-testing:HoneyDueUITests/Suite10_ComprehensiveE2ETests"
)
# Cleanup tests — must run last, sequentially
CLEANUP_TESTS=(
"-only-testing:HoneyDueUITests/SuiteZZ_CleanupTests"
)
run_phase() {
local phase_name="$1"
local result_path="$RESULTS_DIR/${phase_name}.xcresult"
shift
local extra_args=("$@")
rm -rf "$result_path"
xcodebuild test \
-project "$PROJECT" \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-derivedDataPath "$DERIVED_DATA" \
-resultBundlePath "$result_path" \
"${extra_args[@]}" \
2>&1 | tail -30
return ${PIPESTATUS[0]}
}
OVERALL_START=$(date +%s)
# ── Phase 1: Seed ──────────────────────────────────────────────
if [ "$SKIP_SEED" = false ]; then
phase_header "Phase 1/3: Seeding test data (sequential)"
SEED_START=$(date +%s)
if run_phase "SeedTests" "${SEED_TESTS[@]}"; then
SEED_END=$(date +%s)
echo -e "\n${GREEN}✓ Seed phase passed ($(( SEED_END - SEED_START ))s)${RESET}"
else
SEED_END=$(date +%s)
echo -e "\n${RED}✗ Seed phase FAILED ($(( SEED_END - SEED_START ))s)${RESET}"
echo -e "${RED} Cannot proceed without seeded data. Aborting.${RESET}"
exit 1
fi
fi
# ── Phase 2: Parallel Tests ───────────────────────────────────
phase_header "Phase 2/3: Running tests in parallel ($WORKERS workers)"
PARALLEL_START=$(date +%s)
if run_phase "ParallelTests" \
-parallel-testing-enabled YES \
-parallel-testing-worker-count "$WORKERS" \
"${PARALLEL_TESTS[@]}"; then
PARALLEL_END=$(date +%s)
echo -e "\n${GREEN}✓ Parallel phase passed ($(( PARALLEL_END - PARALLEL_START ))s)${RESET}"
PARALLEL_PASSED=true
else
PARALLEL_END=$(date +%s)
echo -e "\n${RED}✗ Parallel phase FAILED ($(( PARALLEL_END - PARALLEL_START ))s)${RESET}"
PARALLEL_PASSED=false
fi
# ── Phase 3: Cleanup ──────────────────────────────────────────
if [ "$SKIP_CLEANUP" = false ]; then
phase_header "Phase 3/3: Cleaning up test data (sequential)"
CLEANUP_START=$(date +%s)
if run_phase "CleanupTests" "${CLEANUP_TESTS[@]}"; then
CLEANUP_END=$(date +%s)
echo -e "\n${GREEN}✓ Cleanup phase passed ($(( CLEANUP_END - CLEANUP_START ))s)${RESET}"
else
CLEANUP_END=$(date +%s)
echo -e "\n${YELLOW}⚠ Cleanup phase failed ($(( CLEANUP_END - CLEANUP_START ))s) — non-blocking${RESET}"
fi
fi
# ── Summary ───────────────────────────────────────────────────
OVERALL_END=$(date +%s)
TOTAL_TIME=$(( OVERALL_END - OVERALL_START ))
phase_header "Summary"
echo " Total time: ${TOTAL_TIME}s"
echo " Workers: $WORKERS"
echo " Results: $RESULTS_DIR/"
echo ""
if [ "$PARALLEL_PASSED" = true ]; then
echo -e " ${GREEN}${BOLD}ALL TESTS PASSED${RESET}"
exit 0
else
echo -e " ${RED}${BOLD}TESTS FAILED${RESET}"
echo -e " Check results: open $RESULTS_DIR/ParallelTests.xcresult"
exit 1
fi