From 9f1a312bb9aef6998772389ea58ee09ba7b062a1 Mon Sep 17 00:00:00 2001 From: dmolinari Date: Sun, 19 Apr 2026 19:21:45 -0300 Subject: [PATCH] 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 --- README.md | 21 +++++++++++++++++++ coverlet.runsettings | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 coverlet.runsettings diff --git a/README.md b/README.md index 39bdfa6..3a61616 100644 --- a/README.md +++ b/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`. diff --git a/coverlet.runsettings b/coverlet.runsettings new file mode 100644 index 0000000..dba2fca --- /dev/null +++ b/coverlet.runsettings @@ -0,0 +1,48 @@ + + + + + + 1 + + + + + + + + cobertura + + + GeneratedCodeAttribute,ExcludeFromCodeCoverageAttribute + + + + + [*.Migrations]*, + + [*.Tests]*, + [SIGCM2.TestSupport]*, + + [SIGCM2.Api]Program, + + [*]*.Extensions.*Extensions, + [*]*.DependencyInjection + + + + true + + + false + + + false + + + + + -- 2.49.1