Unity-Technologies / Unity-Technologies/UnityDataTools
Tests: extract the duplicated console-capture and output-folder scaffolding
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 821
- Fork
- 71
- Merge medio
- 3h 13m
- PR unite (30g)
- 9
Descrizione
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.SQLTestHelperis 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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dai fixture di UnityDataTool.Tests indicati nell’issue, in particolare AnalyzeOverwriteTests, AnalyzeExitCodeTests, FindRefsTests e UnityDataToolPlayerDataTests, e confronta il relativo codice per la cattura dei comandi e la configurazione delle cartelle. Esamina SQLTestHelper prima di scegliere un helper condiviso separato o un fixture di base. Il lavoro è completo quando i pattern duplicati sono stati migrati tra i fixture e la suite di test continua a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- testing-qa
- Tipo di issue
- Refactoring
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100