Unity-Technologies / Unity-Technologies/UnityDataTools
Tests: extract the duplicated console-capture and output-folder scaffolding
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 821
- Forks
- 71
- Ø Merge
- 3 Std. 13 Min.
- Gemergte PRs (30 T.)
- 9
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den in der Issue genannten UnityDataTool.Tests-Fixtures, insbesondere AnalyzeOverwriteTests, AnalyzeExitCodeTests, FindRefsTests und UnityDataToolPlayerDataTests, und vergleiche deren Code zur Erfassung von Befehlen und zur Einrichtung der Ordner. Prüfe SQLTestHelper, bevor du dich für einen separaten gemeinsamen Helper oder eine Basis-Fixture entscheidest. Erledigt ist die Aufgabe, wenn die duplizierten Muster über die Fixtures hinweg migriert wurden und die Testsuite weiterhin erfolgreich durchläuft.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- testing-qa
- Issue-Typ
- Refactoring
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100