d-o-hub

test-optimization

4
0
# Install this skill:
npx skills add d-o-hub/rust-self-learning-memory --skill "test-optimization"

Install specific skill from multi-skill repository

# Description

Advanced test optimization with cargo-nextest, property testing, and performance benchmarking. Use when optimizing test execution speed, implementing property-based tests, or analyzing test performance.

# SKILL.md


name: test-optimization
description: Advanced test optimization with cargo-nextest, property testing, and performance benchmarking. Use when optimizing test execution speed, implementing property-based tests, or analyzing test performance.


Test Optimization

Advanced test optimization with cargo-nextest, property testing, and benchmarking.

cargo-nextest Integration

# Install
cargo install cargo-nextest --locked

# Run all tests
cargo nextest run

# CI profile (with retries)
cargo nextest run --profile ci

Configuration (.config/nextest.toml)

[profile.default]
slow-timeout = { period = "30s", terminate-after = 3 }

[profile.ci]
retries = 2
fail-fast = false
test-threads = 4

Property-Based Testing (proptest)

proptest! {
    #[test]
    fn test_episode_id_uniqueness(
        tasks in prop::collection::vec(any::<String>(), 1..100)
    ) {
        let rt = tokio::runtime::Runtime::new().unwrap();
        rt.block_on(async {
            let memory = setup_memory().await;
            let mut ids = HashSet::new();
            for desc in tasks {
                let id = memory.start_episode(desc, ctx, type_).await;
                prop_assert!(ids.insert(id));
            }
        });
    }
}

Performance Targets

Operation Target Actual
Episode Creation < 50ms ~2.5 µs
Step Logging < 20ms ~1.1 µs
Pattern Extraction < 1000ms ~10.4 µs
Memory Retrieval < 100ms ~721 µs

Best Practices

  • Use nextest profiles for dev/CI separation
  • Implement property tests for edge cases
  • Monitor test duration
  • Track coverage trends

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.