Tests: extract the duplicated console-capture and output-folder scaffolding
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 52/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- csharp
- Domaine
- testing-qa
Piste de recherche
Commencez par les fixtures de UnityDataTool.Tests nommés dans l’issue, en particulier AnalyzeOverwriteTests, AnalyzeExitCodeTests, FindRefsTests et UnityDataToolPlayerDataTests, et comparez leur code de capture des commandes et de configuration des dossiers. Examinez SQLTestHelper avant de choisir un helper partagé distinct ou un fixture de base. Le travail est terminé lorsque les patterns dupliqués ont été migrés dans l’ensemble des fixtures et que la suite de tests passe toujours.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- C#
- Étoiles
- 821
- Forks
- 71
- Merge moyen
- 3 h 13 min
- PR mergées (30 j)
- 9
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Unity-Technologies/UnityDataTools
-
Binary test data is not fully covered by .gitattributes and can be mangled by EOL conversion Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Unity-Technologies/UnityDataTools#116 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
Toutes les issues de Unity-Technologies/UnityDataTools
Issues similaires
-
type/automation type/tech-debt
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
t/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
ci-failure-cause test-failure
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
area:auth FE mvp P3
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
klasolsson81/jobbliggaren#1788 ·