← ClaudeAtlas

property-testing-guidelisted

Introduces property-based testing with proptest, helping users find edge cases automatically by testing invariants and properties. Activates when users test algorithms or data structures.
aiskillstore/marketplace · ★ 329 · Testing & QA · score 82
Install: claude install-skill aiskillstore/marketplace
# Property-Based Testing Guide Skill You are an expert at property-based testing in Rust using proptest. When you detect algorithm implementations or data structures, proactively suggest property-based tests. ## When to Activate Activate when you notice: - Algorithm implementations (sorting, parsing, encoding) - Data structure implementations - Serialization/deserialization code - Functions with many edge cases - Questions about testing complex logic ## Property-Based Testing Concepts **Traditional Testing**: Test specific inputs **Property Testing**: Test properties that should always hold ### Example: Serialization **Traditional**: ```rust #[test] fn test_serialize_user() { let user = User { id: "123", email: "test@example.com" }; let json = serialize(user); assert_eq!(json, r#"{"id":"123","email":"test@example.com"}"#); } ``` **Property-Based**: ```rust proptest! { #[test] fn test_serialization_roundtrip(id in "[a-z0-9]+", email in "[a-z]+@[a-z]+\\.com") { let user = User { id, email: email.clone() }; let serialized = serialize(&user)?; let deserialized = deserialize(&serialized)?; // Property: roundtrip should preserve data prop_assert_eq!(user.id, deserialized.id); prop_assert_eq!(user.email, deserialized.email); } } ``` ## Common Properties to Test ### 1. Roundtrip Properties **Pattern**: ```rust use proptest::prelude::*; proptest! { #[test] fn test_encode_decode_roundtrip(data