Files
MangaReader/ios-app/Tests/run_tests.sh
renato97 b474182dd9 Initial commit: MangaReader iOS App
 Features:
- App iOS completa para leer manga sin publicidad
- Scraper con WKWebView para manhwaweb.com
- Sistema de descargas offline
- Lector con zoom y navegación
- Favoritos y progreso de lectura
- Compatible con iOS 15+ y Sideloadly/3uTools

📦 Contenido:
- Backend Node.js con Puppeteer (opcional)
- App iOS con SwiftUI
- Scraper de capítulos e imágenes
- Sistema de almacenamiento local
- Testing completo
- Documentación exhaustiva

🧪 Prueba: Capítulo 789 de One Piece descargado exitosamente
  - 21 páginas descargadas
  - 4.68 MB total
  - URLs verificadas y funcionales

🎉 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-04 15:34:18 +01:00

256 lines
6.0 KiB
Bash
Executable File

#!/bin/bash
# Script para ejecutar los tests de MangaReader
# Usage: ./run_tests.sh [options]
#
# Options:
# --all Ejecutar todos los tests (default)
# --unit Solo tests unitarios
# --integration Solo tests de integración
# --coverage Ejecutar con cobertura de código
# --verbose Salida detallada
# --clean Limpiar build antes de testear
set -e
# Colores para output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Variables
PROJECT_DIR="/home/ren/ios/MangaReader/ios-app"
SCHEME="MangaReader"
DESTINATION="platform=iOS Simulator,name=iPhone 15"
TEST_TYPE="all"
COVERAGE="NO"
VERBOSE=""
# Funciones de logging
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Banner
print_banner() {
echo -e "${BLUE}"
echo "╔════════════════════════════════════════╗"
echo "║ MangaReader Test Suite Runner ║"
echo "╚════════════════════════════════════════╝"
echo -e "${NC}"
}
# Parsear argumentos
parse_args() {
while [[ $# -gt 0 ]]; do
case $1 in
--all)
TEST_TYPE="all"
shift
;;
--unit)
TEST_TYPE="unit"
shift
;;
--integration)
TEST_TYPE="integration"
shift
;;
--coverage)
COVERAGE="YES"
shift
;;
--verbose)
VERBOSE="-verbose"
shift
;;
--clean)
log_info "Limpiando build..."
clean_build
shift
;;
--help)
show_help
exit 0
;;
*)
log_error "Opción desconocida: $1"
show_help
exit 1
;;
esac
done
}
# Mostrar ayuda
show_help() {
cat << EOF
Usage: ./run_tests.sh [options]
Options:
--all Ejecutar todos los tests (default)
--unit Solo tests unitarios
--integration Solo tests de integración
--coverage Ejecutar con cobertura de código
--verbose Salida detallada
--clean Limpiar build antes de testear
--help Mostrar esta ayuda
Examples:
./run_tests.sh --all --coverage
./run_tests.sh --unit --verbose
./run_tests.sh --clean --coverage
EOF
}
# Limpiar build
clean_build() {
cd "$PROJECT_DIR"
xcodebuild clean -scheme "$SCHEME" 2>&1 | grep -E "error|warning|clean"
}
# Ejecutar todos los tests
run_all_tests() {
log_info "Ejecutando todos los tests..."
xcodebuild test \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-enableCodeCoverage "$COVERAGE" \
$VERBOSE
}
# Ejecutar solo tests unitarios
run_unit_tests() {
log_info "Ejecutando tests unitarios..."
xcodebuild test \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-only-testing:MangaReaderTests/ModelTests \
-only-testing:MangaReaderTests/StorageServiceTests \
-only-testing:MangaReaderTests/ManhwaWebScraperTests \
-enableCodeCoverage "$COVERAGE" \
$VERBOSE
}
# Ejecutar solo tests de integración
run_integration_tests() {
log_info "Ejecutando tests de integración..."
xcodebuild test \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-only-testing:MangaReaderTests/IntegrationTests \
-enableCodeCoverage "$COVERAGE" \
$VERBOSE
}
# Generar reporte de cobertura
generate_coverage_report() {
if [ "$COVERAGE" = "YES" ]; then
log_info "Generando reporte de cobertura..."
# Buscar el archivo de cobertura más reciente
COVERAGE_FILE=$(find ~/Library/Developer/Xcode/DerivedData -name "*.profdata" -print0 | xargs -0 ls -t | head -n1)
if [ -n "$COVERAGE_FILE" ]; then
log_success "Archivo de cobertura: $COVERAGE_FILE"
# Generar reporte HTML (requiere xcrun)
# xcrun llvm-cov report "$COVERAGE_FILE" > coverage_report.txt
log_success "Reporte de cobertura generado"
else
log_warning "No se encontró archivo de cobertura"
fi
fi
}
# Verificar resultado del test
check_test_result() {
if [ $? -eq 0 ]; then
log_success "Todos los tests pasaron ✓"
if [ "$COVERAGE" = "YES" ]; then
generate_coverage_report
fi
echo ""
log_info "Resumen:"
echo " - Tests ejecutados: $TEST_TYPE"
echo " - Cobertura: $COVERAGE"
return 0
else
log_error "Algunos tests fallaron ✗"
return 1
fi
}
# Verificar dependencias
check_dependencies() {
log_info "Verificando dependencias..."
if ! command -v xcodebuild &> /dev/null; then
log_error "xcodebuild no encontrado. Asegúrate de tener Xcode instalado."
exit 1
fi
if [ ! -d "$PROJECT_DIR" ]; then
log_error "Directorio del proyecto no encontrado: $PROJECT_DIR"
exit 1
fi
log_success "Dependencias OK"
}
# Main
main() {
print_banner
parse_args "$@"
check_dependencies
echo ""
log_info "Configuración:"
echo " - Proyecto: $PROJECT_DIR"
echo " - Scheme: $SCHEME"
echo " - Destination: $DESTINATION"
echo " - Test Type: $TEST_TYPE"
echo " - Coverage: $COVERAGE"
echo ""
# Ejecutar tests según tipo
case $TEST_TYPE in
all)
run_all_tests
;;
unit)
run_unit_tests
;;
integration)
run_integration_tests
;;
esac
check_test_result
}
# Ejecutar
main "$@"