Unity-Technologies / Unity-Technologies/UnityDataTools
Tests: extract the duplicated console-capture and output-folder scaffolding
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 821
- 派生
- 71
- 平均合并
- 3 小时 13 分钟
- 30 天内合并 PR
- 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.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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中提到的 UnityDataTool.Tests fixtures 开始,尤其是 AnalyzeOverwriteTests、AnalyzeExitCodeTests、FindRefsTests 和 UnityDataToolPlayerDataTests,并比较它们的命令捕获和文件夹设置代码。在选择单独的共享 helper 或基础 fixture 之前,先检查 SQLTestHelper。完成的标准是:重复的模式已在各个 fixtures 中完成迁移,并且测试套件仍然通过。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- testing-qa
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100