Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Cerrado
#246 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp
Área
testing, tooling

Línea de trabajo

Comienza con el flujo documentado de server-mode y reproduce el problema usando los comandos listados collect, connect, snapshot -r, merge y shutdown para Test A y Test B. Inspecciona las salidas sin procesar de los snapshots antes del procesamiento de merge o mapper; se considera terminado cuando cada snapshot contiene únicamente la cobertura recopilada desde el reset anterior sin corromper el archivo .coverage.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C#
Estrellas
125
Forks
17
Merge medio
1 h 15 min
PR fusionados (30 d)
2

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/codecoverage

Todos los issues de microsoft/codecoverage

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.