跳到正文
cccskills
免费在 GitHub 公开

ripdpi-tdd

Red-green-refactor workflow for RIPDPI plus test-double and FaultQueue conventions. Use when the user asks for test-first work or a defect needs a reproducing test. Not for Kotlin test syntax (use kotlin-test-patterns).

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI星标 82(GitHub 82 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(2)

  • SKILL.md5.4 KB
  • references/testing-anti-patterns.md5.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Test-Driven Development

Full test stack documentation: docs/testing.md. Do not duplicate it here -- read it when you need runner details, CI lanes, or fixture locations. The test rule and the verification policy in AGENTS.md take precedence over this skill.

When to use the cycle

Use red-green-refactor when the user asks for test-first work, or when a defect or new behavior is not caught by an existing test. Search the owning module's tests first: if an existing test covers the behavior, extend it or rely on it instead of adding one. Refactors, renames, and wiring changes need no new test; the existing tests and the module gate prove them.

Workflow

  1. RED -- Write one test for one behavior and run only that test. Confirm it fails for the expected reason. If it passes, the behavior is already covered or the test is wrong.
  2. GREEN -- Write the minimum implementation that makes it pass. Run the same test again.
  3. REFACTOR -- Clean up the test and the implementation, then run the owning module's tests once.

Run the gate that AGENTS.md assigns to the change once, after the last cycle of a batch, not after every cycle.

Running Tests

Kotlin/JVM (fast iteration)

# Single test method
./gradlew :core:engine:testDebugUnitTest --tests "ClassName.method name"

# Single test class
./gradlew :core:engine:testDebugUnitTest --tests "ClassName"

# Single module
./gradlew :core:engine:testDebugUnitTest

Replace :core:engine with the target module (:core:service, :core:data, :core:diagnostics). :app tasks are flavor-qualified (:app:testGithubFullDebugUnitTest).

Rust

# Single test
cargo nextest run --locked -p crate_name test_name

# Single crate
cargo nextest run --locked -p crate_name

Golden contracts

Golden tests are read-only by default. Blessing needs explicit user approval for the affected fixture family; follow golden-bless-discipline.md and the golden-test-management skill.

Test Double Conventions

Fake* classes (no mocking frameworks)

The project uses hand-written Fakes and no MockK, Mockito, or other mocking library. Reuse an existing Fake from the owning module's tests before writing one; shared :core:engine doubles live in core/engine/src/test/kotlin/com/poyka/ripdpi/core/TestDoubles.kt.

  • Name: Fake + interface name (e.g., FakeRipDpiProxyRuntime)
  • Return configurable values set before the test runs
  • Assert the observable result of the code under test. Assert a recorded call only when the call itself is the behavior (for example, that a native stop was requested)

FaultQueue for fault injection

Fault injection uses FaultQueue<T> from core/engine-api/src/main/kotlin/com/poyka/ripdpi/core/testing/FaultModel.kt.

Key types:

  • FaultQueue<T> -- ordered queue of faults matched by target enum
  • FaultSpec<T> -- target + outcome + scope + optional message/payload
  • FaultScope.ONE_SHOT -- fires once then is consumed
  • FaultScope.PERSISTENT -- fires on every matching call until cleared
  • FaultOutcome -- EXCEPTION, TIMEOUT, DROP, RESET, MALFORMED_PAYLOAD, BLANK_PAYLOAD, PANIC

Usage in tests:

val bindings = FakeRipDpiProxyBindings()
bindings.faults.enqueue(
    FaultSpec(
        target = ProxyBindingFaultTarget.START,
        outcome = FaultOutcome.EXCEPTION,
        message = "simulated native crash",
    )
)

Test Organization by Layer

What you testLocationRunner
Kotlin business logiccore/*/src/test/./gradlew :core:*:testDebugUnitTest
Rust native logicnative/rust/crates/*/tests/cargo nextest run --locked -p crate
JNI integrationapp/src/androidTest/.../integration/connectedGithubFullDebugAndroidTest
Network E2Eapp/src/androidTest/.../e2e/connectedGithubFullDebugAndroidTest
Rust network E2Enative/rust/crates/*/tests/bash scripts/ci/run-rust-network-e2e.sh

Rules

  1. Fake doubles only.* No mocking frameworks.
  2. FaultQueue for error paths. Use FaultSpec + FaultQueue, not ad-hoc exception throwing.
  3. Use backtick names in Kotlin tests. @Test fun proxy start propagates native exception().
  4. Use snake_case names in Rust tests. fn proxy_start_propagates_native_exception().
  5. Test and implementation land in one commit. Never commit a test without its implementation or vice versa.
  6. Prefer unit tests. Escalate to integration or E2E only when the behavior needs real Android or network components.

Common Mistakes

MistakeFix
Using MockK or MockitoWrite or reuse a Fake* class
Adding a test an existing test already coversExtend or rely on the existing test
Asserting only a Fake's recorded callsAssert the observable result
runBlocking in coroutine testsUse runTest from kotlinx-coroutines-test
Testing private internalsTest through the public API of the class under test
FaultScope.PERSISTENT when ONE_SHOT sufficesDefault to ONE_SHOT; use PERSISTENT only for repeated-call scenarios

For deeper coverage of anti-patterns, see references/testing-anti-patterns.md.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

RIPDPI's own Compose conventions: ViewModel pattern, Route/Screen split, DataStore->StateFlow, RipDpiThemeTokens. Use for how this app does Compose, not generic Compose API questions (see compose).

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI822026年10月27日 更新

ADB-based RIPDPI device/emulator debugging: build/install/launch, logcat filtering, fixture port-forwarding, instrumented tests, crash/ANR triage. Use when debugging on a real device or emulator.

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI822026年10月27日 更新

RIPDPI Appium launch-contract reference: start routes and permission/service/data presets. Use when a test launches to the wrong screen or a new automation route is added. General flakiness: appium-test-debug.

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI822026年10月27日 更新

RIPDPI Appium test authoring: page objects, resource-id locators, assertions, wait tiers. Use when writing a new Appium test or page object, or adding coverage for a new screen.

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI822026年10月27日 更新

RIPDPI Appium failure triage: flaky tests, locator/session/wait issues, screenshot and element-tree debugging. Use when an Appium test fails or is flaky.

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI822026年10月27日 更新

Add or modify a GitHub Actions job. Use when editing a file under .github/workflows/. Not for running a workflow locally (local-ci-act) or release signing (release-signing).

中文简介正在准备中。当前显示原文说明。

po4yka/RIPDPI822026年10月27日 更新

查看 po4yka 的全部技能

报告此技能的问题