| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente |
| eadl:bloc3:dev_av:tests [2025/09/17 00:18] – jcheron | eadl:bloc3:dev_av:tests [2025/09/17 00:41] (Version actuelle) – [SpringBoot-GitHub] jcheron |
|---|
| * Archive les rapports (téléchargeables depuis l’onglet “Actions” de Github). | * Archive les rapports (téléchargeables depuis l’onglet “Actions” de Github). |
| |
| | === Couverture JaCoCo === |
| | Ajoute la configuration JaCoCo+Surefire dans **pom.xml** : |
| | |
| | Ajouter les numéros de version : |
| | |
| | <sxh xml;gutter:false> |
| | <properties> |
| | <java.version>17</java.version> |
| | <kotlin.version>1.9.25</kotlin.version> |
| | <maven.compiler.source>${java.version}</maven.compiler.source> |
| | <maven.compiler.target>${java.version}</maven.compiler.target> |
| | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | <maven.surefire.plugin.version>3.2.5</maven.surefire.plugin.version> |
| | <jacoco.version>0.8.12</jacoco.version> |
| | </properties> |
| | </sxh> |
| | Ajouter les 2 plugins Maven suivants : |
| | |
| | <sxh xml;gutter:false> |
| | <build> |
| | <plugins> |
| | <plugin> |
| | <groupId>org.apache.maven.plugins</groupId> |
| | <artifactId>maven-surefire-plugin</artifactId> |
| | <version>${maven.surefire.plugin.version}</version> |
| | <configuration> |
| | <useModulePath>false</useModulePath> |
| | </configuration> |
| | </plugin> |
| | |
| | <plugin> |
| | <groupId>org.jacoco</groupId> |
| | <artifactId>jacoco-maven-plugin</artifactId> |
| | <version>${jacoco.version}</version> |
| | <executions> |
| | <execution> |
| | <goals> |
| | <goal>prepare-agent</goal> |
| | </goals> |
| | </execution> |
| | <execution> |
| | <id>report</id> |
| | <phase>test</phase> |
| | <goals> |
| | <goal>report</goal> |
| | </goals> |
| | </execution> |
| | </executions> |
| | </plugin> |
| | </plugins> |
| | </build> |
| | </sxh> |
| | |
| | Le rapport de couverture (téléchargeable via actions) : |
| | |
| | <html><div class="imageB"></html> |
| | {{:eadl:bloc3:dev_av:pasted:20250917-002448.png}} |
| | <html></div></html> |
| | |
| | === Seuil de couverture === |
| | Ajout d'une exécution jacoco:check pour échouer sous le seuil de 80% de couverture : |
| | |
| | <sxh xml;gutter:false> |
| | <execution> |
| | <id>check</id> |
| | <goals><goal>check</goal></goals> |
| | <configuration> |
| | <rules> |
| | <rule> |
| | <element>BUNDLE</element> |
| | <limits> |
| | <limit> |
| | <counter>INSTRUCTION</counter> |
| | <value>COVEREDRATIO</value> |
| | <minimum>0.80</minimum> |
| | </limit> |
| | </limits> |
| | </rule> |
| | </rules> |
| | </configuration> |
| | </execution> |
| | </sxh> |
| | |
| | === Bonnes pratiques CI === |
| | * Protéger la branche master : |
| | * Settings → Branches → Add rule → exiger le job “CI • Tests (Maven)” avant merge. |
| | * Déclencheurs: |
| | * Pour limiter le bruit: exécuter seulement sur PR ou sur changements Java/Maven: |
| | |
| | <sxh yml;gutter:false> |
| | on: |
| | pull_request: |
| | branches: [ master ] |
| | paths: [ 'src/**', 'pom.xml', '.github/workflows/**' ] |
| | </sxh> |
| |
| |
| |