用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-rust --skill rust-testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | rust-testing |
| description | Master Rust testing - unit tests, integration tests, mocking, and TDD |
| sasmp_version | 1.3.0 |
| bonded_agent | rust-tooling-agent |
| bond_type | SECONDARY_BOND |
| version | 1.0.0 |
Master comprehensive testing in Rust: unit tests, integration tests, doc tests, property testing, and mocking.
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add_positive() {
assert_eq!(add(2, 3), 5);
}
#[test]
fn test_add_negative() {
assert_eq!(add(-1, -1), -2);
}
#[test]
#[should_panic(expected = "overflow")]
fn test_overflow() {
panic!("overflow");
}
#[test]
#[ignore]
fn expensive_test() {
// Run with: cargo test -- --ignored
}
}
// tests/integration_test.rs
use my_crate::public_api;
#[test]
fn test_full_workflow() {
let result = public_api::process("input");
assert!(result.is_ok());
}
mod common; // tests/common/mod.rs
#[test]
fn test_with_setup() {
let ctx = common::setup();
// test...
}
/// Adds two numbers.
///
/// # Examples
///
/// ```
/// let result = my_lib::add(2, 2);
/// assert_eq!(result, 4);
/// ```
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
cargo test # All tests
cargo test test_name # Specific test
cargo test -- --nocapture # Show output
cargo test -- --ignored # Ignored tests
cargo test --doc # Doc tests only
cargo nextest run # Fast parallel
#[tokio::test]
async fn test_async_operation() {
let result = async_function().await;
assert!(result.is_ok());
}
use proptest::prelude::*;
proptest! {
#[test]
fn test_commutative(a in 0i32..1000, b in 0i32..1000) {
assert_eq!(add(a, b), add(b, a));
}
}
use mockall::automock;
#[automock]
trait Database {
fn get(&self, id: u32) -> Option<String>;
}
#[test]
fn test_with_mock() {
let mut mock = MockDatabase::new();
mock.expect_get()
.returning(|_| Some("data".to_string()));
}
| Problem | Solution |
|---|---|
| Test not found | Check module path |
| Async fails | Add #[tokio::test] |
| Random failures | Use --test-threads=1 |