37 lines
973 B
PowerShell
37 lines
973 B
PowerShell
$RepoRoot = Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "..")
|
|
|
|
Push-Location -Path $RepoRoot
|
|
|
|
try {
|
|
Write-Host "Starting test execution..." -ForegroundColor Magenta
|
|
Write-Host ""
|
|
|
|
$TestResultsPath = Join-Path -Path $RepoRoot -ChildPath "TestResults"
|
|
|
|
if (Test-Path $TestResultsPath) {
|
|
Remove-Item -Path $TestResultsPath -Recurse -Force
|
|
}
|
|
|
|
dotnet test
|
|
|
|
$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
|