Run-Tests.ps1
|
# Test Runner for HermesConsoleUI v2.1.0 # Ejecuta todos los tests y genera reporte param( [switch]$UnitOnly, [switch]$IntegrationOnly, [switch]$Coverage, [string]$OutputFormat = "NUnitXml" ) Write-Host "=== HermesConsoleUI Test Suite v2.1.0 ===" -ForegroundColor Cyan Write-Host "" # 1. Definir rutas de tests $testPaths = @() if (-not $IntegrationOnly) { $testPaths += Join-Path $PSScriptRoot "tests/Unit" $testPaths += Join-Path $PSScriptRoot "tests/Hygiene" $testPaths += Join-Path $PSScriptRoot "tests/Performance" $testPaths += Join-Path $PSScriptRoot "tests/ui_components.tests.ps1" } if (-not $UnitOnly) { $testPaths += Join-Path $PSScriptRoot "tests/Integration" } # Filtrar rutas que existen $existingPaths = $testPaths | Where-Object { Test-Path $_ } if ($existingPaths.Count -eq 0) { Write-Host "❌ No se encontraron rutas de test válidas." -ForegroundColor Red exit 1 } # 2. Verificar que Pester está instalado $pester = Get-Module -ListAvailable Pester if (-not $pester) { Write-Host "⚠️ Pester no está instalado. Intentando cargar..." -ForegroundColor Yellow } # 3. Ejecutar tests Write-Host "Ejecutando tests con Pester..." -ForegroundColor Yellow Write-Host "Rutas: $($existingPaths -join ', ')" -ForegroundColor Gray $pesterParams = @{ Path = $existingPaths PassThru = $true } # Ejecutar Invoke-Pester $result = Invoke-Pester @pesterParams # 4. Resumen Write-Host "" Write-Host "=== Resumen de Tests ===" -ForegroundColor Cyan if ($result) { Write-Host " Passed: $($result.PassedCount)" -ForegroundColor Green Write-Host " Failed: $($result.FailedCount)" -ForegroundColor $(if ($result.FailedCount -gt 0) { "Red" } else { "Green" }) if ($result.FailedCount -gt 0) { Write-Host "❌ Tests FAILED" -ForegroundColor Red exit 1 } else { Write-Host "✅ All tests PASSED" -ForegroundColor Green exit 0 } } else { Write-Host "⚠️ No se recibieron resultados de Pester." -ForegroundColor Yellow exit 1 } |