Unity-Technologies / Unity-Technologies/UnityDataTools

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

オープン
#139 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C#
スター
821
フォーク
71
平均マージ
3時間 13分
マージ済み PR(30日)
9

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

issueで挙げられているUnityDataTool.Testsのfixture、特にAnalyzeOverwriteTests、AnalyzeExitCodeTests、FindRefsTests、UnityDataToolPlayerDataTestsから着手し、それらのコマンドキャプチャとフォルダーセットアップのコードを比較してください。別の共有ヘルパーまたはベースfixtureを選ぶ前に、SQLTestHelperを確認してください。重複したパターンがfixture全体にわたって移行され、テストスイートが引き続きパスすれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
testing-qa
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。