Support GitLab-compatible Cobertura format in MTP natively

Aperta
#190 5 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp
Ambito
testing-qa

Direzione di ricerca

Inizia eseguendo il comando dotnet documentato con --coverage-output-format cobertura e analizza l'XML Cobertura generato. Confronta i nomi dei file delle classi e la struttura dei package con i percorsi relativi e le sorgenti richiesti da GitLab; il lavoro è completato quando l'output nativo funziona senza i comandi sed di post-elaborazione e conserva dati di coverage validi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello 👋,

I’m currently using GitLab, which supports displaying code coverage information directly inside the diff view of a merge request. It relies on the Cobertura format for this feature.

Previously, when I was using coverlet, this worked perfectly out of the box. However, after switching to Microsoft.Testing.Platform and the Microsoft.Testing.Extensions.CodeCoverage package, the coverage report stopped working in GitLab.

After some experimentation, I was able to make it work again by manually tweaking the generated Cobertura XML file:

dotnet run -c Release -- --report-junit --coverage --coverage-output-format cobertura --coverage-output myapp.cobertura.xml
sed -i "s@filename=\"$CI_PROJECT_DIR/@filename=\"@g" bin/Release/net9.0/TestResults/myapp.cobertura.xml
sed -i "s@<packages>@<sources><source>$CI_PROJECT_DIR/</source></sources><packages>@g" bin/Release/net9.0/TestResults/myapp.cobertura.xml

The idea here is:

  • Replace all absolute paths in the nodes with relative paths.
  • Add a node containing the base path.

This makes GitLab correctly display coverage information in merge requests.
However, having to run these sed commands after each test run is not ideal.

👉 Question:
Is there already a built-in option or configuration to achieve this behavior natively?
And if not, would it be possible to add support for relative paths and sources in the Cobertura output?

Thanks a lot for your work on this project!

Lingua principale
C#
Stelle
125
Fork
17
Merge medio
1h 17m
PR unite (30g)
2

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/codecoverage

Tutte le issue di microsoft/codecoverage

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.