chore: update test script to allow running from anywhere and also clean up test results on each run
This commit is contained in:
1 parent
7ad14767b6
commit
e6891a72ea
1 file changed
+27
-13
+27
-13
@@ -1,22 +1,36 @@
|
|||||||
Write-Host "Starting test execution..." -ForegroundColor Magenta
|
$RepoRoot = Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "..")
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
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) {
|
if (Test-Path $TestResultsPath) {
|
||||||
Write-Host ""
|
Remove-Item -Path $TestResultsPath -Recurse -Force
|
||||||
Write-Host "Tests passed. Generating code coverage HTML report..." -ForegroundColor Magenta
|
}
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"CoverageReport"
|
dotnet test
|
||||||
|
|
||||||
Write-Host ""
|
$TestExitCode = $LASTEXITCODE
|
||||||
Write-Host "SUCCESS: All tests passed and coverage report generated." -ForegroundColor Green
|
|
||||||
} else {
|
if ($TestExitCode -eq 0) {
|
||||||
Write-Host "FAILURE: Tests failed with exit code $TestExitCode. Skipping coverage report generation." -ForegroundColor Red
|
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
|
exit $TestExitCode
|
||||||
Reference in new issue
Block a user