79 lines
2.7 KiB
PowerShell
79 lines
2.7 KiB
PowerShell
# Run Aniworld Robot Framework tests on Windows (PowerShell)
|
|
# Usage: .\run.ps1 [-SuitePattern "api/auth.robot"]
|
|
# Examples:
|
|
# .\run.ps1 # Run all tests
|
|
# .\run.ps1 -SuitePattern "api/" # Run all API tests
|
|
# .\run.ps1 -SuitePattern "ui/" # Run all UI tests
|
|
|
|
param(
|
|
[string]$SuitePattern = "tests/robot/"
|
|
)
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
|
$robotDir = Split-Path -Parent $scriptDir
|
|
$projectDir = Split-Path -Parent $robotDir
|
|
$resultsDir = Join-Path $robotDir "results"
|
|
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Aniworld Robot Framework Test Runner" -ForegroundColor Cyan
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
Write-Host "Project dir: $projectDir"
|
|
Write-Host "Results dir: $resultsDir"
|
|
Write-Host "Suite pattern: $SuitePattern"
|
|
Write-Host ""
|
|
|
|
# Ensure we're in the project directory
|
|
Set-Location $projectDir
|
|
|
|
# Check Python
|
|
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
|
|
Write-Error "Error: python not found in PATH"
|
|
exit 1
|
|
}
|
|
|
|
# Install/update Robot Framework dependencies
|
|
Write-Host "Installing Robot Framework dependencies..." -ForegroundColor Yellow
|
|
& python -m pip install -q robotframework robotframework-browser robotframework-requests robotframework-jsonlibrary 2>$null
|
|
|
|
# Initialize Browser library (Playwright)
|
|
Write-Host "Initializing Browser library (Playwright)..." -ForegroundColor Yellow
|
|
& python -m Browser.entry init 2>$null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Warning "Browser library init may need manual run: 'rfbrowser init'"
|
|
}
|
|
|
|
# Create results directory
|
|
New-Item -ItemType Directory -Force -Path $resultsDir | Out-Null
|
|
|
|
# Run tests
|
|
Write-Host ""
|
|
Write-Host "Running Robot Framework tests..." -ForegroundColor Green
|
|
Write-Host "----------------------------------------" -ForegroundColor Green
|
|
|
|
& robot `
|
|
--outputdir $resultsDir `
|
|
--logtitle "Aniworld Test Log" `
|
|
--reporttitle "Aniworld Test Report" `
|
|
--metadata Project:Aniworld `
|
|
--metadata Environment:"$(& python --version)" `
|
|
--variable BASE_URL:http://127.0.0.1:8765 `
|
|
--variable BROWSER:chromium `
|
|
--variable HEADLESS:True `
|
|
$SuitePattern
|
|
|
|
$exitCode = $LASTEXITCODE
|
|
|
|
Write-Host ""
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
if ($exitCode -eq 0) {
|
|
Write-Host "All tests PASSED" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Some tests FAILED (exit code: $exitCode)" -ForegroundColor Red
|
|
}
|
|
Write-Host "Report: $resultsDir\report.html"
|
|
Write-Host "Log: $resultsDir\log.html"
|
|
Write-Host "Output: $resultsDir\output.xml"
|
|
Write-Host "========================================" -ForegroundColor Cyan
|
|
|
|
exit $exitCode
|