# scripts/test-lane.ps1 # Runs tests filtered by lane (Unit, Contract, Integration, Security, Performance, Live) # # Usage: # .\scripts\test-lane.ps1 Unit # .\scripts\test-lane.ps1 Integration -ResultsDirectory .\test-results # .\scripts\test-lane.ps1 Security -Logger "trx;LogFileName=security-tests.trx" [CmdletBinding()] param( [Parameter(Mandatory=$true, Position=0)] [ValidateSet('Unit', 'Contract', 'Integration', 'Security', 'Performance', 'Live')] [string]$Lane, [Parameter(ValueFromRemainingArguments=$true)] [string[]]$DotNetTestArgs ) $ErrorActionPreference = 'Stop' Write-Host "Running tests for lane: $Lane" -ForegroundColor Cyan # Build trait filter for xUnit # Format: --filter "Lane=$Lane" $filterArg = "--filter", "Lane=$Lane" # Build full dotnet test command $testArgs = @( 'test' $filterArg '--configuration', 'Release' '--no-build' ) + $DotNetTestArgs Write-Host "Executing: dotnet $($testArgs -join ' ')" -ForegroundColor Gray # Execute dotnet test & dotnet $testArgs if ($LASTEXITCODE -ne 0) { Write-Error "Tests failed with exit code $LASTEXITCODE" exit $LASTEXITCODE } Write-Host "Lane '$Lane' tests completed successfully" -ForegroundColor Green