c34cc41496
- Dockerfile multi-stage (build eclipse-temurin:25-jdk → runtime) - CI : tests via actions/setup-java puis build & push vers registry Gitea - Trigger Watchtower après push sur main - CLAUDE.md + rules projet (.claude/rules/) - Version build.gradle : 0.0.1-SNAPSHOT → 0.0.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
64 lines
1.6 KiB
Markdown
64 lines
1.6 KiB
Markdown
# 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 :
|
|
|
|
```bash
|
|
podman run --rm -v $(pwd):/workspace:Z -w /workspace eclipse-temurin:25-jdk ./gradlew test --no-daemon
|
|
```
|
|
|
|
Testcontainers nécessite le socket Docker/Podman :
|
|
|
|
```bash
|
|
podman run --rm \
|
|
-v $(pwd):/workspace:Z \
|
|
-v /run/user/$(id -u)/podman/podman.sock:/var/run/docker.sock \
|
|
-w /workspace \
|
|
eclipse-temurin:25-jdk \
|
|
./gradlew test --no-daemon
|
|
```
|
|
|
|
## JaCoCo dans build.gradle
|
|
|
|
```groovy
|
|
test {
|
|
useJUnitPlatform()
|
|
finalizedBy jacocoTestReport
|
|
}
|
|
|
|
jacocoTestReport {
|
|
reports { xml.required = true }
|
|
dependsOn test
|
|
}
|
|
|
|
jacocoTestCoverageVerification {
|
|
violationRules {
|
|
rule {
|
|
limit { minimum = 0.90 }
|
|
}
|
|
}
|
|
}
|
|
```
|