Token导航 LogoToken导航TokenDH.com
研究检索需要联网clawhub未标认证来源可访问clear审计通过

rust-testing-code-reviewRust 测试代码审查

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

8,436

周安装

338

GitHub Stars

公开资料未说明

下载量

2,731
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:rust-testing-code-review(Rust 测试代码审查)
来源仓库:https://github.com/anderskev/rust-testing-code-review
安装命令:
openclaw skills install rust-testing-code-review
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install rust-testing-code-review

简介

专门审查 Rust 测试代码的结构与质量,提升自动化测试覆盖率。

  • 支持单元测试、集成测试、异步测试和基于属性的测试分析。
  • 可识别模拟方法误用和夹具数据冗余等问题点。rust-testing-code-review 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 使用前需确认项目采用的标准测试框架(如 cargo test)。
  • 建议区分本地模拟与真实服务调用,避免测试污染生产数据。

SKILL.md

name
rust-testing-code-review
description
Reviews Rust test code for unit test patterns, integration test structure, async testing, mocking approaches, and property-based testing. Covers Rust 2024 edition changes including async fn in traits for mocks, #[expect] lint suppression, LazyLock test fixtures, and temporary scope changes affecting test assertions. Use when reviewing _test.rs files, #[cfg(test)] modules, or test infrastructure in Rust projects. Covers tokio::test, test fixtures, and assertion patterns.

Rust Testing Code Review

Review Workflow

  1. Check Rust edition — Note edition in Cargo.toml (2021 vs 2024). Edition 2024 changes temporary scoping in if let and tail expressions, and makes #[expect] the preferred lint suppression
  2. Check test organization — Unit tests in #[cfg(test)] modules, integration tests in tests/ directory
  3. Check async test setup#[tokio::test] for async tests, proper runtime configuration. Check for async-trait on mocks that could use native async fn in traits
  4. Check assertions — Meaningful messages, correct assertion type. Review if let assertions for edition 2024 temporary scope changes
  5. Check test isolation — No shared mutable state between tests, proper setup/teardown. Prefer LazyLock over lazy_static!/once_cell for shared fixtures
  6. Check coverage patterns — Error paths tested, edge cases covered

Gates (hard)

Do not advance to Output Format until each pass condition is satisfied (yes/no with a concrete artifact).

  1. Edition recorded — Open the target crate’s Cargo.toml (or workspace [workspace.package] / inherited edition) and note the edition value. Pass: you can quote edition = "…" (or document “inherited from workspace”) before citing Rust 2024–specific behavior (if let / tail temporary drops, #[expect] vs #[allow] migration, native async fn in traits as default). If edition is not 2024, do not report those items as edition-2024 regressions; at most Informational if still useful.
  2. dyn vs static async mocks — Before suggesting native async fn in traits instead of async-trait, check whether the mock is used as dyn Trait. Pass: if dyn is required, you either skip that suggestion or align with Valid Patterns (async-trait still needed).
  3. Verification protocolPass: steps from beagle-rust:review-verification-protocol are done before any finding is listed (see Before Submitting Findings).

Output Format

Report findings as:

[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.

Quick Reference

Issue TypeReference
Unit tests, assertions, naming, snapshots, rstest, doc tests, #[expect], LazyLock fixtures, tail expression scopereferences/unit-tests.md
Integration tests, async testing, fixtures, test databases, native async fn mocks, if let temporary scopereferences/integration-tests.md
Fuzzing, property-based testing, Miri, Loom, benchmarking, compile_fail, custom harness, mocking strategiesreferences/advanced-testing.md

Review Checklist

Test Structure

  • [ ] Unit tests in #[cfg(test)] mod tests within source files
  • [ ] Integration tests in tests/ directory (one file per module or feature)
  • [ ] use super::* in test modules to access parent module items
  • [ ] Test function names describe the scenario: test_<function>_<scenario>_<expected>
  • [ ] Tests are independent — no reliance on execution order

Async Tests

  • [ ] #[tokio::test] used for async test functions
  • [ ] #[tokio::test(flavor = "multi_thread")] when testing multi-threaded behavior
  • [ ] No block_on inside async tests (use .await directly)
  • [ ] Test timeouts set for tests that could hang
  • [ ] Mock traits use native async fn instead of async-trait crate (stable since Rust 1.75)

Assertions

  • [ ] assert_eq! / assert_ne! used for value comparisons (better error messages than assert!)
  • [ ] Custom messages on assertions that aren't self-documenting
  • [ ] matches! macro used for enum variant checking
  • [ ] Error types checked with matches! or pattern matching, not string comparison
  • [ ] One assertion per test where practical (easier to diagnose failures)
  • [ ] if let assertions reviewed for edition 2024 temporary scope — temporaries in conditions drop earlier, may invalidate borrows
  • [ ] Tail expression returns reviewed for edition 2024 — temporaries in tail expressions drop before local variables

Mocking and Test Doubles

  • [ ] Traits used as seams for dependency injection (not concrete types)
  • [ ] Mock implementations kept minimal — only what the test needs
  • [ ] No mocking of types you don't own (wrap external dependencies behind your own trait)
  • [ ] Test fixtures as helper functions, not global state
  • [ ] std::sync::LazyLock used for shared test fixtures instead of lazy_static! or once_cell (stable since Rust 1.80)

Error Path Testing

  • [ ] Result::Err variants tested, not just happy paths
  • [ ] Specific error variants checked (not just "is error")
  • [ ] #[should_panic] used sparingly — prefer Result-returning tests

Lint Suppression in Tests

  • [ ] #[expect(lint)] used instead of #[allow(lint)] for test-specific suppressions (stable since Rust 1.81)
  • [ ] Justification comment on every #[expect] or #[allow] in test code
  • [ ] Stale #[allow] attributes migrated to #[expect] for self-cleaning behavior

Test Naming

  • [ ] Test names read like sentences describing behavior (not test_happy_path)
  • [ ] Related tests grouped in nested mod blocks for organization
  • [ ] Test names follow pattern: <function>_should_<behavior>_when_<condition>

Snapshot Testing

  • [ ] cargo insta used for complex structural output (JSON, YAML, HTML, CLI output)
  • [ ] Snapshots are small and focused (not huge objects)
  • [ ] Redactions used for unstable fields (timestamps, UUIDs)
  • [ ] Snapshots committed to git in snapshots/ directory
  • [ ] Simple values use assert_eq!, not snapshots

Parametrized Testing

  • [ ] rstest used to avoid duplicated test functions for similar inputs
  • [ ] #[rstest] with #[case::name] attributes for descriptive parametrized tests
  • [ ] #[fixture] used for shared test setup when multiple tests need same construction
  • [ ] Parametrized tests still have descriptive case names (not just #[case(1)])
  • [ ] Combined with async: #[rstest] #[tokio::test] for async parametrized tests

Doc Tests

  • [ ] Public API functions have /// # Examples with runnable code
  • [ ] Doc tests serve as both documentation and correctness checks
  • [ ] Hidden setup lines prefixed with # to keep examples clean
  • [ ] cargo test --doc passes (nextest doesn't run doc tests)

Severity Calibration

Critical

  • Tests that pass but don't actually verify behavior (assertions on wrong values)
  • Shared mutable state between tests causing flaky results
  • Missing error path tests for security-critical code

Major

  • #[should_panic] without expected message (catches any panic, including wrong ones)
  • unwrap() in test setup that hides the real failure location
  • Tests that depend on execution order
  • if let with inline temporary in assertion that breaks under edition 2024 temporary scoping
  • async-trait on mock traits when native async fn in traits is available and project targets edition 2024

Minor

  • Missing assertion messages on complex comparisons
  • assert!(x == y) instead of assert_eq!(x, y) (worse error messages)
  • Test names that don't describe the scenario
  • Redundant setup code that could be extracted to a helper
  • #[allow] used where #[expect] would provide self-cleaning suppression
  • lazy_static! or once_cell used for test fixtures when LazyLock is available

Informational

  • Suggestions to add property-based tests via proptest or quickcheck
  • Suggestions to add snapshot testing for complex output
  • Coverage improvement opportunities

Valid Patterns (Do NOT Flag)

  • unwrap() / expect() in tests — Panicking on unexpected errors is the correct test behavior
  • **use super::* in test modules** — Standard pattern for accessing parent items
  • #[allow(dead_code)] on test helpers — Helper functions may not be used in every test
  • clone() in tests — Clarity over performance
  • Large test functions — Integration tests can be long; extracting helpers isn't always clearer
  • assert! for boolean checks — Fine when the expression is clearly boolean (.is_some(), .is_empty())
  • Multiple assertions testing one logical behavior — Sometimes one behavior needs multiple checks
  • unwrap() on Result-returning test functions — Propagating with ? is also fine but not required
  • async-trait on mock traits requiring dyn dispatch — Native async fn in traits doesn't support dyn Trait; async-trait is still needed there
  • #[expect] with justification on test helpers — Self-cleaning lint suppression is correct in test code
  • LazyLock for expensive shared test fixtures — Thread-safe lazy init is appropriate for test globals

Before Submitting Findings

Load and follow beagle-rust:review-verification-protocol before reporting any issue.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

74.21%
按下载量换算2,027

安全审计

VirusTotal

未展示

ClawScan

通过

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills