chore: update test script to allow running from anywhere and also clean up test results on each run

This commit is contained in:
Stevan Freeborn committed 2026-08-28 09:13:59 -05:00
1 parent 7ad14767b6
commit e6891a72ea
1 file changed
+27 -13
+27 -13
View File
@@ -1,22 +1,36 @@
Write-Host "Starting test execution..." -ForegroundColor Magenta
Write-Host ""
$RepoRoot = Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "..")
dotnet test
Push-Location -Path $RepoRoot
try {
Write-Host "Starting test execution..." -ForegroundColor Magenta
Write-Host ""
$TestExitCode = $LASTEXITCODE
$TestResultsPath = Join-Path -Path $RepoRoot -ChildPath "TestResults"
if ($TestExitCode -eq 0) {
Write-Host ""
Write-Host "Tests passed. Generating code coverage HTML report..." -ForegroundColor Magenta
Write-Host ""
if (Test-Path $TestResultsPath) {
Remove-Item -Path $TestResultsPath -Recurse -Force
}
reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"CoverageReport"
dotnet test
Write-Host ""
Write-Host "SUCCESS: All tests passed and coverage report generated." -ForegroundColor Green
} else {
Write-Host "FAILURE: Tests failed with exit code $TestExitCode. Skipping coverage report generation." -ForegroundColor Red
$TestExitCode = $LASTEXITCODE
if ($TestExitCode -eq 0) {
Write-Host ""
Write-Host "Tests passed. Generating code coverage HTML report..." -ForegroundColor Magenta
Write-Host ""
reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"CoverageReport"
Write-Host ""
Write-Host "SUCCESS: All tests passed and coverage report generated." -ForegroundColor Green
} else {
Write-Host "FAILURE: Tests failed with exit code $TestExitCode. Skipping coverage report generation." -ForegroundColor Red
}
}
finally {
Pop-Location
}
exit $TestExitCode