Unity-Technologies / Unity-Technologies/UnityDataTools

Tests: extract the duplicated console-capture and output-folder scaffolding

Abierto
#139 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
C#
Estrellas
821
Forks
71
Merge medio
3 h 13 min
PR fusionados (30 d)
9

Descripción

The test fixtures in UnityDataTool.Tests each re-implement the same two pieces of scaffolding.

Running a command and capturing its output. Every fixture that needs to assert on what a command
printed redirects Console.Out / Console.Error into a StringWriter, calls Program.Main, and
restores the originals in a finally. There are three named variants of this —
AnalyzeOverwriteTests.RunAnalyze (stderr only), AnalyzeExitCodeTests.RunAnalyze (both streams),
FindRefsTests.RunFindRefsOn — plus a large number of copies written inline inside individual test
methods, for example the two no-TypeTree tests in UnityDataToolPlayerDataTests.

Output folder setup and teardown. OneTimeSetup creates a per-fixture folder under the test
directory and SetCurrentDirectorys into it; Teardown calls SqliteConnection.ClearAllPools() and
deletes the folder's files and subdirectories. This block is duplicated nearly verbatim across
roughly 15 fixtures.

Neither is causing bugs, but it means a change to how tests run a command or clean up has to be made
in many places, and each new fixture starts by copying 40 lines.

Suggested shape:

  • A shared helper that runs a command and returns (exitCode, stdout, stderr) — or combined output,
    which is what most assertions want. SQLTestHelper is the project's existing shared helper but is
    SQL-specific, so a small separate helper class is probably a better home.
  • A base fixture (or a helper method) for the output-folder creation and teardown.

Then migrate the fixtures over, which can be done incrementally.

Raised during the review of the fix for #115, which added one more copy of both patterns.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

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.

Línea de trabajo

Empieza por los fixtures de UnityDataTool.Tests mencionados en el issue, especialmente AnalyzeOverwriteTests, AnalyzeExitCodeTests, FindRefsTests y UnityDataToolPlayerDataTests, y compara su código de captura de comandos y configuración de carpetas. Revisa SQLTestHelper antes de elegir un helper compartido independiente o un fixture base. Se considera terminado cuando los patrones duplicados se hayan migrado en todos los fixtures y la suite de pruebas siga pasando.

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

Evaluación

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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.