proptest-testing
БесплатноБез исполняемых скриптовНе проверенUse for any question or task about property-based or generated-input tests in Rust, including quick how-to questions, round-trip checks and parsers that crash…
от testland★ 18 звёзд на GitHubОб этом скилле
proptest-testing
Overview
Per proptest-readme:
"Proptest is a property testing framework inspired by Python's Hypothesis. It automatically generates test inputs and shrinks failures to minimal cases."
"Strategy-based approach: Unlike QuickCheck, generation is 'defined on a per-value basis instead of per-type,' enabling flexible composition." (proptest-readme)
The strategy-based design is the key differentiator from Rust's
quickcheck crate - proptest separates the generation strategy
from the type, so multiple strategies can produce the same type
without newtype wrappers.
"Failure persistence: Failed test cases are saved for regression testing." (proptest-readme)
This means a failed property test produces a proptest-regressions/
file checked into git; future runs replay it before generating new
cases.
When to use
- A Rust codebase has functions with structured inputs (parsers, serializers, validators, encoders).
- A bug fix needs property-level prevention (not just an example test).
- Round-trip / invariant properties hold
(
decode(encode(x)) == x,sort(sort(x)) == sort(x)). - A refactor needs equivalence verification (new vs old produce same outputs for all inputs).
Install
In Cargo.toml:
[dev-dependencies]
proptest = "1"
Note: per proptest-readme, "the crate mainly sees passive maintenance" - the API is stable; new development is rare.
Basic property
Per proptest-readme:
use proptest::prelude::*;
proptest! {
#[test]
fn parses_valid_dates(s in "[0-9]{4}-[0-9]{2}-[0-9]{2}") {
parse_date(&s).unwrap();
}
}
The proptest! macro wraps a #[test]-style function. The
parameter declaration s in "..." says "generate s from the
regex strategy."
Per proptest-readme, one of proptest's distinguishing
features is regex-based string generation: "[0-9]{4}-[0-9]{2}-[0-9]{2}"
generates date-shaped strings without writing a custom strategy.
Strategy catalog
| Strategy | Generates |
|---|---|
any::<T>() |
Any value of type T (uses default strategy) |
0..100i32 |
Integers in range |
"[a-z]+" (regex string) |
Strings matching regex |
prop::collection::vec(strategy, 0..10) |
Vec of length 0-10 |
prop::collection::hash_map(k, v, 0..10) |
HashMap |
prop::collection::btree_set(s, 0..10) |
BTreeSet |
(s1, s2, s3) (tuple) |
Tuple of values |
Just(value) |
Constant |
prop_oneof![s1, s2, s3] |
One of multiple strategies |
s.prop_map(f) |
Transform via function |
s.prop_filter("reason", f) |
Filter (with reason for shrinking) |
s.prop_flat_map(f) |
Dependent generation |
For custom domain strategies with prop_compose! and the
round-trip / invariant / equivalence property patterns they feed,
see
references/strategies-and-patterns.md.
Configuration
proptest! {
#![proptest_config(ProptestConfig {
cases: 1000, // default 256
max_shrink_iters: 100, // default 1024
..ProptestConfig::default()
})]
#[test]
fn expensive_property(x in any::<u64>()) {
// ...
}
}
Common config options:
| Field | Default | Use |
|---|---|---|
cases |
256 | More for higher confidence; slower CI. |
max_shrink_iters |
1024 | Cap shrinking time on slow tests. |
max_shrink_time |
0 | Time-based shrink cap (ms; 0 = unlimited). |
verbose |
0 | 0 / 1 / 2 - verbosity level. |
failure_persistence |
enabled | Persist failed cases to proptest-regressions/. |
Failure persistence (the regression file)
When a property fails, proptest writes:
# proptest-regressions/my_module.txt
# Seeds for failure cases proptest has generated in the past.
# It is recommended to commit this file.
cc abc1234567890 # shrinks to s = "1900-02-30"
Commit this file to git. Future runs replay these seeds before generating new cases - locks the regression in.
If the regression is no longer relevant (the bug was fixed via a different code path that doesn't fail this ca
Установить proptest-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл proptest-testing?
Use for any question or task about property-based or generated-input tests in Rust, including quick how-to questions, round-trip checks and parsers that crash on fuzzed input: proptest with the proptest! macro, strategies for collections, regex strings and any, shrinking, and the persisted regression file.
Как установить скилл proptest-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл proptest-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic