Support GitLab-compatible Cobertura format in MTP natively

Đang mở
#190 5 bình luận 3 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
testing-qa

Hướng nghiên cứu

Bắt đầu bằng cách chạy lệnh dotnet được tài liệu hóa với --coverage-output-format cobertura và kiểm tra XML Cobertura được tạo ra. So sánh tên tệp lớp và cấu trúc gói của nó với các đường dẫn tương đối và nguồn mà GitLab yêu cầu; được xem là hoàn tất khi đầu ra native hoạt động mà không cần các lệnh sed hậu xử lý và vẫn bảo toàn dữ liệu coverage hợp lệ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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!

Ngôn ngữ chính
C#
Star
125
Fork
17
Merge trung bình
1 giờ 17 phút
Pull request đã merge (30 ngày)
2

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/codecoverage

Tất cả issue của microsoft/codecoverage

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.