Logo Testing On The Toilet

Testing On The Toilet

Cộng đồng
shamashel
testing-on-the-toilet

Apply Google Testing on the Toilet (TotT) rules when writing tests, reviewing a test diff, choosing mocks vs fakes, diagnosing brittle or change-detector tests, DAMP vs DRY test structure, SMURF/pyramid layer choice, or flaky time/sleep/shared-fixture tests. Instructs what a good test asserts and what to refuse. Not a Vitest/runner cookbook and not an E2E authoring workflow.

Tổng quan

Nhà phát hànhshamashel
Kho mãtesting-on-the-toilet
Tên kỹ năngtesting-on-the-toilet
Sao
36
Bản fork
0
Tệp đi kèm
1
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được shamashel công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Testing On The Toilet trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/shamashel/testing-on-the-toilet/tree/main/skills/testing-on-the-toilet
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/shamashel/testing-on-the-toilet.git /tmp/testing-on-the-toilet
mkdir -p .claude/skills
cp -r /tmp/testing-on-the-toilet/skills/testing-on-the-toilet .claude/skills/testing-on-the-toilet
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Testing On The Toilet trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Testing On The Toilet ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Testing On The Toilet với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Testing on the Toilet

Distilled from Google's Testing on the Toilet episodes (2007–2026). Episode index: references/episodes.md.

Run this loop on every new test and every test you review. Completion: each test that ships would fail on a real behavior bug and would survive a behavior-preserving refactor.

1. Change-detector gate

A change-detector restates production structure (especially ordered verify of every collaborator call) without checking an observable result. Correct and incorrect implementations pass equally; any rename/extract/reorder fails the suite.

Rewrite it to assert state, return value, rendered output, or persisted data. If you cannot name the user-visible contract, delete the test and say why. Do not "fix" a refactor by mechanically updating fifty mirrors.

Interaction verify is allowed only when the call itself is the contract (send mail once, do not double-charge, presenter tells the view to show X). If unsure, rewrite to a state/return assertion; if that is impossible, stop and ask which observable outcome the test protects.

2. Pick the cheapest layer that still has fidelity

Name the bug/risk first. Pick the topmost row in the table that can catch it. Escalate a row only when a cheaper layer would miss that risk (state the miss). SMURF (Speed, Maintainability, Utilization/cost, Reliability, Fidelity) is the tradeoff language when two rows could both catch it: prefer the cheaper/faster/more reliable one.

RiskLayer
Pure logic, parsing, validation, reducersFast unit through the public API
Collaborators you own, in-processReal objects or an owner-maintained fake
Service/HTTP contractOwner fake or hermetic server — not a handwritten request mock
UI wiring (disabled, unbound, hidden)Drive the rendered control (click/type), not the handler
Cross-system critical pathTiny e2e set: one path per use case plus key error classes; assert system outcomes, not copy/layout

Brainstorm key risks before stacking layers. Coverage meters find gaps; they do not certify quality. Cover both sides of a branch (the implicit else counts). Skip exhaustive combinatorics; extract predicates and cover each independently.

Prefer testing through the public API. Exhaustive tests of private helpers for inputs callers never pass are change-detectors in disguise.

3. Choose the double

Order: real → fake → stub → mock. Mock last.

  • Real when it is fast, deterministic, in-process.
  • Fake: simplified working impl of a type you (or the library owner) maintain. Keep it narrow. Contract-test fake vs real when the fake is shared.
  • Stub: canned returns for queries. Do not verify getters.
  • Mock: verify side-effecting calls whose interaction is the spec.

Hard rules:

  • Do not mock types you don't own. Wrap the third-party API; mock the wrapper; test the wrapper against the real library.
  • Mocking more than one or two collaborators, or a long when/verify chain, is a seam smell — extract a narrower port and fake that.
  • Inject long-lived collaborators in the constructor; pass per-call work as method arguments. No hidden singletons, unmockable statics, or now() inside the logic under test.

4. Author the test (DAMP)

DAMP (descriptive and meaningful phrases) beats DRY in tests. Tests have no tests — a reader must see cause next to effect in the method body.

  • One behavior per test. Name unit_scenario_expectedOutcome (or the project's equivalent). testFoo is not a name.
  • Arrange–act–assert in one block. Shared @Before soup that lives far from the assertion is how wrong expected values sneak in.
  • Helpers hide irrelevant construction. Scenario-relevant fields stay visible in the test. Builder/factory with defaults is good; silently asserting a helper default is not.
  • Literal inputs and expected outputs. Do not compute the expectation with loops/conditionals that can share a bug with production. If a helper must contain logic, unit-test the helper.
  • Narrow assertions: the fields under test, not the whole object/screenshot/hash order. One full-equality check for the common happy object is enough.
  • Distinct non-default values per input (0, "", first enum can match uninitialized state and fake a pass).
  • Actionable failures: precise matchers (containsEntry, isOk with error text) over assertTrue(result.ok()). Independent checks should continue (EXPECT) unless later asserts are meaningless (ASSERT file opened).
  • Floats: tolerance, never exact equality.
  • UI locators: stable test IDs, not copy or brittle XPath.

5. Hermetic and deterministic

No real clock, no sleep as synchronization, no live network/disk in unit tests, no shared files/rows assumed empty.

  • Inject a clock; tick it.
  • Wait on latches/events with a timeout, or advance a fake scheduler.
  • Unique temp paths / isolated fixtures per test.
  • Force rare failures (timeouts, thrown errors) through the double — live infra cannot.

6. Prove the test can fail

When writing or editing locally: run green, then break production (or invert the assertion) and confirm red. When reviewing and you cannot run: write the one concrete behavior bug this assertion would catch; if you cannot, treat it as a change-detector and do not approve.

When refactoring tests, put production in a known-broken state first so dropped assertions show up; then restore production. Never green-to-green "cleanup" of tests without that check.

If the only remaining test is a tautology, a mock-script of the implementation, or wiring with no logic: do not add it. Report the missing seam or the layer that should own the risk instead.

If project conventions conflict with a hard rule here (required mock-all-collaborators, sleep-based waits, tests of private helpers only): stop and cite the conflict. Do not silently follow the weaker convention.

Review checklist

A test you would merge:

  • Would fail on a real behavior bug, not only on a rename/extract
  • Asserts a result/state, not a call script (unless the call is the contract)
  • Public API / user-facing path, not an unreachable helper
  • Cause and effect visible; name states the outcome
  • Deterministic (clock/IO/uniqueness handled)
  • Failure message would start the fix without extra logging

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Testing On The Toilet làm được gì?

Apply Google Testing on the Toilet (TotT) rules when writing tests, reviewing a test diff, choosing mocks vs fakes, diagnosing brittle or change-detector tests, DAMP vs DRY test structure, SMURF/pyramid layer choice, or flaky time/sleep/shared-fixture tests. Instructs what a good test asserts and what to refuse. Not a Vitest/runner cookbook and not an E2E authoring workflow.

Vì sao nên dùng Testing On The Toilet trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Testing On The Toilet là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Testing On The Toilet trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/shamashel/testing-on-the-toilet/tree/main/skills/testing-on-the-toilet. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Testing On The Toilet?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Testing On The Toilet với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Testing On The Toilet với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Testing On The Toilet có miễn phí không?

Kỹ năng này được shamashel phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇