Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

dotnet-coverage collect --server-mode leaks coverage across tests when using snapshot -r

クローズ
#246 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp
領域
testing, tooling

調査の方向性

ドキュメント化された server-mode のフローから始め、Test A と Test B について、一覧にある collect、connect、snapshot -r、merge、shutdown コマンドを使って問題を再現します。merge または mapper による処理の前に raw snapshot 出力を調べます。各 snapshot に直前の reset 以降に収集された coverage だけが含まれ、.coverage ファイルが破損していなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

We are observing that in a long-lived server-mode session, calling snapshot -r does not appear to fully clear prior coverage state. Coverage from an earlier test is still present in the next snapshot, and the raw .coverage file is already corrupted before any mapper/parsing logic executes. This is causing to collect the per test coverage when the test cases needs to run in sequence.

Steps:

  1. Start a shared coverage session:
    cmd : dotnet-coverage collect --server-mode --background --session-id
    2. Connect and run Test A in that same session:
    cmd : dotnet-coverage connect dotnet test
    3. Snapshot Test A with reset:
    cmd : dotnet-coverage snapshot -r -o -t
    dotnet-coverage merge -o -f xml
    4. Connect and run Test B in the same session:
    cmd : dotnet-coverage connect dotnet test
    5. Snapshot Test B with reset:
    cmd : dotnet-coverage snapshot -r -o -t
    dotnet-coverage merge -o -f xml
    6. Observe coverage contamination between Test A and Test B.
    7. Shut down the server at the end
    cmd: dotnet-coverage shutdown -t

Expected:
Each snapshot should produce coverage for only the test that executed since the previous reset. The -r option should clear the previous coverage state after creating the snapshot.

Actual:
The second snapshot still contains coverage from the earlier test or from a previous unrelated run. The raw .coverage output is already incorrect before mapper logic runs, which indicates the issue is in the coverage engine/server-mode reset behavior and not in downstream parsing.

Impact:
Incorrect coverage attribution, false pass/fail evidence, broken file-to-test mapping.

Note:
This issue is specific to dotnet-coverage collect --server-mode with repeated snapshot -r calls in the same process/session. It is not the same as MTP JSON-RPC server mode (--server / --server jsonrpc), which is a separate feature for IDE/tooling integration. The bug is therefore in the coverage collector/server-mode flow, not in the MTP test runner or mapper logic.

Relevant docs:

https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-code-coverage
https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-server-mode
https://github.com/microsoft/codecoverage

主要言語
C#
スター
125
フォーク
17
平均マージ
1時間 15分
マージ済み PR(30日)
2

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/codecoverage のほかの issue

microsoft/codecoverage の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。