Maverick Rust Testing

Rust testing patterns (unit, integration, property-based) Use when this capability is needed.

tomevault-io 95c2073 2 files · 1.7 KB Updated

File contents

Rust Testing Skill

Unit Tests

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_add() {
        assert_eq!(add(2, 2), 4);
    }

    #[test]
    #[should_panic(expected = "overflow")]
    fn test_overflow() {
        add(i32::MAX, 1);
    }
}

Integration Tests

Place in tests/ directory (separate crate).

Property-Based Testing

use proptest::prelude::*;

proptest! {
    #[test]
    fn test_reverse_involutive(ref vec in prop::collection::vec(any::<i32>(), 0..100)) {
        let reversed_twice: Vec<_> = vec.iter().rev().rev().cloned().collect();
        assert_eq!(vec, &reversed_twice);
    }
}

Review Severity

  • CRITICAL: No tests for new code
  • MAJOR: Missing edge case tests
  • MINOR: Missing documentation on tests

Converted and distributed by TomeVault — claim your Tome and manage your conversions.

tomevault-io/skills-registry/tree/main/get2knowio--maverick--maverick-rust-testing commit 95c207393b

Frequently asked questions

npx skillmds@latest add tomevault-io/maverick-rust-testing