chore(infra): configure coverlet for backend C# coverage
Add coverlet.runsettings with Cobertura format, exclusions for migrations, DI wiring, Program.cs and auto-props. Document coverage commands in README. coverlet.collector 6.0.4 was already present via Directory.Packages.props. Coverage baseline (Application.Tests + Api.Tests combined): - Application.Tests: line 80.9%, branch 65.3% - Api.Tests: line 64.9%, branch 57.8% Closes #48
This commit is contained in:
21
README.md
21
README.md
@@ -73,6 +73,27 @@ dotnet test tests/SIGCM2.Api.Tests # integration (requiere SIGCM2_
|
||||
cd src/web && npx vitest run
|
||||
```
|
||||
|
||||
### Coverage (backend)
|
||||
|
||||
```bash
|
||||
# Generar reporte de coverage en formato Cobertura
|
||||
dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings --results-directory ./TestResults
|
||||
```
|
||||
|
||||
El comando genera un `coverage.cobertura.xml` por cada proyecto de test en `./TestResults/`.
|
||||
|
||||
Para convertirlo a HTML:
|
||||
|
||||
```bash
|
||||
# Instalar ReportGenerator (solo la primera vez)
|
||||
dotnet tool install -g dotnet-reportgenerator-globaltool
|
||||
|
||||
# Generar reporte HTML
|
||||
reportgenerator -reports:"./TestResults/**/coverage.cobertura.xml" -targetdir:"./coverage-report" -reporttypes:Html
|
||||
```
|
||||
|
||||
Abrí `./coverage-report/index.html` en el browser para ver el detalle por archivo.
|
||||
|
||||
## Convenciones
|
||||
|
||||
- Ramas: `feature/UDT-XXX` desde `main`.
|
||||
|
||||
48
coverlet.runsettings
Normal file
48
coverlet.runsettings
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RunSettings>
|
||||
<!--
|
||||
Configuracion de coverage con coverlet.collector.
|
||||
Uso: dotnet test /collect:"XPlat Code Coverage" /settings:coverlet.runsettings /results-directory:./TestResults
|
||||
-->
|
||||
<RunConfiguration>
|
||||
<!-- Mantener ejecución secuencial (hereda política de tests.runsettings) -->
|
||||
<MaxCpuCount>1</MaxCpuCount>
|
||||
</RunConfiguration>
|
||||
|
||||
<DataCollectionRunSettings>
|
||||
<DataCollectors>
|
||||
<DataCollector friendlyName="XPlat Code Coverage">
|
||||
<Configuration>
|
||||
<!-- Formato de salida: cobertura (compatible con ReportGenerator y CI/CD) -->
|
||||
<Format>cobertura</Format>
|
||||
|
||||
<!-- Exclusiones por atributo generado -->
|
||||
<ExcludeByAttribute>GeneratedCodeAttribute,ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>
|
||||
|
||||
<!-- Exclusiones por tipo/namespace -->
|
||||
<Exclude>
|
||||
<!-- Migrations embebidas (SQL scripts, no lógica de negocio) -->
|
||||
[*.Migrations]*,
|
||||
<!-- Los proyectos de test no se miden a sí mismos -->
|
||||
[*.Tests]*,
|
||||
[SIGCM2.TestSupport]*,
|
||||
<!-- Program.cs: host wiring, no testeable unitariamente -->
|
||||
[SIGCM2.Api]Program,
|
||||
<!-- Extension methods de DI: una línea por registro, ruido sin valor -->
|
||||
[*]*.Extensions.*Extensions,
|
||||
[*]*.DependencyInjection
|
||||
</Exclude>
|
||||
|
||||
<!-- No medir las propiedades auto-implementadas -->
|
||||
<SkipAutoProps>true</SkipAutoProps>
|
||||
|
||||
<!-- No incluir el assembly de tests en el reporte -->
|
||||
<IncludeTestAssembly>false</IncludeTestAssembly>
|
||||
|
||||
<!-- Permitir timestamps reales en el reporte (no forzar determinismo) -->
|
||||
<DeterministicReport>false</DeterministicReport>
|
||||
</Configuration>
|
||||
</DataCollector>
|
||||
</DataCollectors>
|
||||
</DataCollectionRunSettings>
|
||||
</RunSettings>
|
||||
Reference in New Issue
Block a user