unit-test-quality/test-data-management penalise real in-memory implementations and require mocks
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- testing-qa
調査の方向性
Start by locating the rules and tests for unit-test-quality-standards and test-data-management, then trace how they determine whether tests use mocks. The issue offers two alternative directions, so clarify which behavior is wanted before changing anything. Done means the tests cover the chosen policy and real in-memory implementations are no longer penalized unfairly.
索引モデルが issue の本文から書いたものです。
説明
Version: 7.17.6
Laws: unit-test-quality-standards, test-data-management
What happens
Both laws report against test suites that deliberately use real in-memory
implementations instead of mocks:
• Dependencies found but no mocking detected in .../launch.page.spec.ts
• Dependencies found but no mocking detected in .../capability-matrix.spec.ts
• External dependencies are not properly mocked in tests
Every one of those files is a suite we would hold up as an example. The laws
are asking us to weaken them.
Why this is the wrong direction
A mock asserts that the code agrees with the test author's belief about a
collaborator, rather than with the collaborator. Two concrete cases from this
repository:
1. InMemoryPlatformCapabilityService runs the same resolution function
and the same capability matrix as production. Only the reported environment
differs. Mocking it would mean asserting against a hand-written table that can
drift from the real matrix — which is exactly the bug the tests exist to catch.
2. InMemoryResourceEnvironment keeps a real monotonic clock and a real
task queue that the test advances. It replaced a faked-timer approach precisely
because fake timers hide the ordering bugs a polling primitive is prone to:
overlapping refreshes, a stale alarm firing after teardown, a poll scheduled
from inside a finally.
Both are strictly stronger than mocking the collaborator away. Under these laws
they score worse than a suite full of jest.fn() that asserts nothing about
real behaviour.
That is the definition of a checkbox that lies, and it is the one thing our
engineering canon forbids outright — so we are reporting it rather than
complying, and rather than waiving it.
Suggested fix
Two options, either would work:
- Detect test doubles by role, not by framework. A class named
InMemory*/Fake*/Stub*injected in place of a real collaborator is
a test double. The current check appears to look only for a mocking library. - Invert the law toward the property that matters: "a unit test must not
reach real I/O — no network, no filesystem, no wall clock". That is what
mocking is a means to, and it can be detected directly. A suite using real
in-memory implementations passes it honestly; a suite that quietly hits the
network fails it, which today's version does not catch.
(2) would also have caught a genuine bug in a sibling repository, where a test
was found to be making a live network call.
- 主要言語
- TypeScript
- スター
- 0
- フォーク
- 0
- 平均マージ
- 38分
- マージ済み PR(30日)
- 96
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Rule-Of-Code/RoC のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Rule-Of-Code/RoC#436 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
Rule-Of-Code/RoC#439 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 49/100
Rule-Of-Code/RoC#438 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 53/100
Rule-Of-Code/RoC#437 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
Rule-Of-Code/RoC#435 ·
メンテナーはふだん 1 日以内に返信
Rule-Of-Code/RoC の issue をすべて見る
似ている issue
-
documentation lens:human needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
thebristolsound/birdbrain#2246 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug ready-for-human
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
BoardGamesEmpire/board-games-empire-backend#1452 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
good first issue stretch
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信