Unity-Technologies / Unity-Technologies/UnityDataTools

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

Đang mở
#139 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
821
Fork
71
Merge trung bình
3 giờ 13 phút
Pull request đã merge (30 ngày)
9

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các fixture của UnityDataTool.Tests được nêu trong issue, đặc biệt là AnalyzeOverwriteTests, AnalyzeExitCodeTests, FindRefsTests và UnityDataToolPlayerDataTests, rồi so sánh mã thiết lập thư mục và mã ghi nhận lệnh của chúng. Xem xét SQLTestHelper trước khi chọn một helper dùng chung riêng biệt hoặc một fixture cơ sở. Công việc được xem là hoàn tất khi các mẫu bị trùng lặp đã được chuyển đổi trong toàn bộ các fixture và test suite vẫn vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
testing-qa
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.