75 lines
3.0 KiB
PowerShell
75 lines
3.0 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
|
|
# Script pour exécuter uniquement les tests unitaires (sans @QuarkusTest)
|
|
# et générer le rapport de couverture JaCoCo
|
|
|
|
Write-Host "Execution des tests unitaires BTPXpress" -ForegroundColor Green
|
|
Write-Host "================================================" -ForegroundColor Green
|
|
|
|
# Nettoyer le projet
|
|
Write-Host "Nettoyage du projet..." -ForegroundColor Yellow
|
|
mvn clean
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Erreur lors du nettoyage" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Exécuter les tests unitaires seulement (exclure les tests d'intégration)
|
|
Write-Host "Execution des tests unitaires..." -ForegroundColor Yellow
|
|
mvn test "-Dtest=!**/*IntegrationTest,!**/integration/**/*Test,!**/*QuarkusTest" "-Dmaven.test.failure.ignore=false" "-Dquarkus.test.profile=test"
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Certains tests ont echoue" -ForegroundColor Red
|
|
Write-Host "Consultez les rapports dans target/surefire-reports/" -ForegroundColor Yellow
|
|
} else {
|
|
Write-Host "Tous les tests unitaires ont reussi !" -ForegroundColor Green
|
|
}
|
|
|
|
# Générer le rapport JaCoCo
|
|
Write-Host "Generation du rapport de couverture..." -ForegroundColor Yellow
|
|
mvn jacoco:report
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Erreur lors de la generation du rapport JaCoCo" -ForegroundColor Yellow
|
|
} else {
|
|
Write-Host "Rapport JaCoCo genere avec succes !" -ForegroundColor Green
|
|
}
|
|
|
|
# Afficher les statistiques de couverture
|
|
if (Test-Path "target/site/jacoco/jacoco.xml") {
|
|
Write-Host "Statistiques de couverture :" -ForegroundColor Cyan
|
|
|
|
try {
|
|
$xml = [xml](Get-Content target/site/jacoco/jacoco.xml)
|
|
$totalInstructions = $xml.report.counter | Where-Object { $_.type -eq "INSTRUCTION" }
|
|
$covered = [int]$totalInstructions.covered
|
|
$total = [int]$totalInstructions.missed + $covered
|
|
$percentage = [math]::Round(($covered / $total) * 100, 2)
|
|
|
|
Write-Host "COUVERTURE GLOBALE: $covered/$total instructions ($percentage%)" -ForegroundColor Green
|
|
|
|
# Objectif de couverture
|
|
$targetCoverage = 80
|
|
if ($percentage -ge $targetCoverage) {
|
|
Write-Host "Objectif de couverture atteint ! ($percentage% >= $targetCoverage%)" -ForegroundColor Green
|
|
} else {
|
|
$remaining = $targetCoverage - $percentage
|
|
Write-Host "Objectif de couverture : $remaining% restants pour atteindre $targetCoverage%" -ForegroundColor Yellow
|
|
}
|
|
|
|
} catch {
|
|
Write-Host "Erreur lors de la lecture du rapport JaCoCo : $($_.Exception.Message)" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Write-Host "Fichier de rapport JaCoCo non trouve" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Afficher les liens vers les rapports
|
|
Write-Host "Rapports generes :" -ForegroundColor Cyan
|
|
Write-Host " - Tests Surefire : target/surefire-reports/" -ForegroundColor White
|
|
Write-Host " - Couverture JaCoCo : target/site/jacoco/index.html" -ForegroundColor White
|
|
|
|
Write-Host "================================================" -ForegroundColor Green
|
|
Write-Host "Execution terminee !" -ForegroundColor Green
|