rust-testing
Patterns for Rust testing in Axone CosmWasm contracts. Use when adding unit tests, integration tests, data-driven cases, or coverage-oriented test scenarios.
适合你,如果你需要在 Rust 智能合约中添加测试用例
/ 通过 npx 安装 校验哈希
npx oh-my-skill add axone-protocol/contracts/rust-testing/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- axone-protocol/contracts/rust-testing/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify axone-protocol/contracts/rust-testing安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
124GitHub stars
~404最小装载
~1.3K含声明引用
~1.3K文本包总量
索引托管
怎么用
商店整理自技能原文 · 版本 7a14fd6 · 表述以原文为准它做什么
Claude 会按照设定的覆盖率目标(如处理器100%、状态操作100%等)和测试设计规则(如隔离测试、描述性命名),生成 Rust 单元测试、集成测试、数据驱动用例或覆盖导向测试场景的代码。
什么时候触发
当用户要求给 Rust 合约添加单元测试、集成测试、数据驱动用例或覆盖导向测试场景时触发。
装好后可以这样说
生成符合覆盖率目标的测试。
使用元组驱动结构。
技能原文 SKILL.md
Rust Testing
Coverage Targets
| Component | Target | | -------------------- | ------ | | Handlers | 100% | | State operations | 100% | | Error paths | 90%+ | | Message parsing | 80%+ | | Overall | 90%+ |
Minimum Cases to Cover
- For handlers: cover the happy path, parameter variations, error paths, and resulting state changes.
- For queries: cover empty state, populated state, pagination behavior, and non-existent items.
- For state transitions: cover initial state, updates after execute, and persistence across operations.
Running Tests
# Run all unit tests cargo make test-unit # Run all tests (includes integration) cargo make test # Run tests with coverage cargo make test-coverage # Run specific test cargo test test_name -- --nocapture
Coverage output is written to lcov.info.
Viewing Coverage
# Generate HTML report (requires lcov) genhtml lcov.info --output-directory coverage/ # Or use cargo-llvm-cov directly cargo llvm-cov --html --open
Test Design Rules
- Isolate tests. Each test should set up its own environment.
- Test contract behavior, not framework internals.
- Assert exact errors when possible.
- Cover edge cases such as zero values, empty strings, and upper bounds.
- Prefer descriptive test names without a
test_prefix. - Use tuple-driven cases for simple matrices and structs only when the case shape needs named fields.
References
- For cw-orch integration harness patterns and common integration scenarios, read [integration-patterns](./references/integration-patterns.md).
- For naming and data-driven test examples, read [test-style](./references/test-style.md).
按 BSD-3-Clause 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…