12a28af1ca
- Champ `name` ajouté sur User, UserEntity, RegisterRequest - AuthenticateUserUseCase retourne Result(user, token) au lieu du token seul - UserNotFoundException remplacé par BadCredentialsException au login (pas de fuite d'info) - @Email retiré de LoginRequest (identifiant = "gato", pas nécessairement un email) - Migration V2 : colonne name + utilisateur par défaut gato/change (ADMIN) - bytecode cible Java 21 (ASM Spring Boot 3.4 ne supporte pas Java 25) - Tests : AbstractIntegrationTest simplifié, URL TC JDBC + network host Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
Tests — Olhar-API
Couverture minimale : 90%
La couverture (lignes, branches, méthodes) doit être ≥ 90% en permanence, vérifiée via JaCoCo.
Le seuil global est défini dans les règles workspace (tests.md).
Types de tests
| Type | Outil | Suffixe de classe |
|---|---|---|
| Unitaire | JUnit 5 | *Test |
| Intégration | JUnit 5 + Testcontainers + PostgreSQL | *IT |
Les tests d'intégration étendent AbstractIntegrationTest qui démarre un conteneur PostgreSQL via Testcontainers.
Structure attendue
Pour chaque classe de production, une classe de test correspondante :
JwtService→JwtServiceTest(unitaire, pas de Spring context)AuthController→AuthControllerIT(intégration,@SpringBootTest)UserRepositoryAdapter→ test d'intégration avec BDD réelle
Exécution via Podman (obligatoire)
Voir java-env.md (règles workspace) pour les contraintes. Commande standard :
podman run --rm -v $(pwd):/workspace:Z -w /workspace eclipse-temurin:25-jdk ./gradlew test --no-daemon
Testcontainers nécessite le socket Podman et le réseau hôte (DinD) :
podman run --rm \
--privileged \
--network host \
-v $(pwd):/workspace:Z \
-v /run/user/$(id -u)/podman/podman.sock:/var/run/docker.sock:Z \
-e DOCKER_HOST=unix:///var/run/docker.sock \
-e TESTCONTAINERS_RYUK_DISABLED=true \
-w /workspace \
eclipse-temurin:25-jdk \
./gradlew test --no-daemon
--network hostest obligatoire : le TC JDBC driver démarre PostgreSQL via le socket Podman et s'y connecte vialocalhost:PORT— sans host network, ce port n'est pas accessible depuis l'intérieur du container.TESTCONTAINERS_RYUK_DISABLED=true: Ryuk (le garbage collector de Testcontainers) ne fonctionne pas en DinD.
JaCoCo dans build.gradle
test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
jacocoTestReport {
reports { xml.required = true }
dependsOn test
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit { minimum = 0.90 }
}
}
}