rust-testing
単体テスト、統合テスト、非同期テスト、プロパティベーステスト、モック、カバレッジを含むRustテストパターン。TDD方法論に従う。
Original · translation is not supported for this source languageTarget: Software development & testing. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original Japanese text
Topics in the source
- Rust テストパターン
- 使用場面
- 動作原理
- RustのTDDワークフロー
- RED-GREEN-REFACTOR サイクル
- Rustでの段階的TDD
- 単体テスト
- モジュールレベルのテスト整理
TDD方法論に従って信頼性が高く保守しやすいテストを書くための包括的なRustテストパターン。 新しいRustの関数、メソッド、またはトレイトを書く場合 既存のコードにテストカバレッジを追加する場合 パフォーマンスクリティカルなコードのベンチマークを作成する場合 入力検証にプロパティベーステストを実装する場合 RustプロジェクトでTDDワークフローに従う場合 1. ターゲットコードを特定する — テストする関数、トレイト、またはモジュールを見つける 2. テストを書く — #[cfg(test)] モジュール内で #[test] を使用、rstest でパラメータ化テスト、または proptest でプロパティベーステスト 3. 依存関係をモックする — mockall を使用してテスト対象のユニットを分離する 4. テストを実行する (RED) — テストが期待通りに失敗することを確認する 5. 実装する (GREEN) — テストを通過するための最小限のコードを書く 6. リファクタリングする — テストを通過したまま、コードを改善する 7. カバレッジを確認する — cargo-llvm-cov を使用し、80%以上を目標にする | コードの種類 | 目標 | |-----------|--------| | クリティカルなビジネスロジック | 100% | | パブリックAPI | 90%以上 | | 汎用コード | 80%以上 | | 生成済み / FFIバインディング | 除外 | すべきこと: まずテストを書く (TDD) 単体テストには #[cfg(test)] モジュールを使用する 実装ではなく動作をテストする シナリオを説明する記述的なテスト名を使用する より良いエラーメッセージのために assert! より asserteq! を優先する クリーンなエラー出力のために Result を返すテストでは ? を使用する テストを独立させる——共有の可変状態なし すべきでないこと: Result::iserr() をテストできる場合に #[shouldpanic] を使用する すべてをモックする——可能なら統合テストを優先する フレーキーなテストを無視する——修正または分離する テストで sleep() を使用する——チャンネル、バリア、または tokio::time::pause() を使用する エラーパスのテストをスキップする 覚えておくこと:テストはドキュメントである。コードをどのように使うべきかを示している。明確に書き、最新の状態を保つこと。
- Source repository
- affaan-m/ECC
- Source file
- docs/ja-JP/skills/rust-testing/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Requirements
- Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.
A small first task
先阅读原作者说明,再决定是否在自己的 AI 工具中使用。
Instructions for your AI tool
- Claude Desktop: resource-specific guide not available yet
- Claude Code: resource-specific guide not available yet
- Cursor: resource-specific guide not available yet
- Codex: resource-specific guide not available yet
Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:49.645Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.