nw-pbt-go

Solid

Go property-based testing with rapid and gopter frameworks

Testing & QA 526 stars 55 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
91
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# PBT Go -- rapid, gopter ## Framework Selection | Framework | Shrinking | Stateful | API Style | Choose When | |-----------|-----------|----------|-----------|-------------| | rapid | Internal (Hypothesis-like) | Yes (StateMachine) | Idiomatic Go (`*rapid.T`) | Default choice. Simpler API, better shrinking. | | gopter | Type-based | Yes (commands) | Explicit generator construction | Need maximum control over generation | **Default**: rapid. More idiomatic Go API and fully automatic shrinking. ## Quick Start (rapid) ```go import ( "sort" "testing" "pgregory.net/rapid" ) func TestSortPreservesLength(t *testing.T) { rapid.Check(t, func(t *rapid.T) { xs := rapid.SliceOf(rapid.Int()).Draw(t, "xs") sorted := make([]int, len(xs)) copy(sorted, xs) sort.Ints(sorted) if len(sorted) != len(xs) { t.Fatalf("length changed: %d -> %d", len(xs), len(sorted)) } }) } // Run: go test ``` ## Generator Cheat Sheet (rapid) ### Primitives ```go rapid.Int() // any int rapid.IntRange(0, 99) // bounded rapid.Int32() rapid.Float64() rapid.String() rapid.StringN(1, 50, -1) // min 1, max 50 chars rapid.Bool() rapid.Byte() ``` ### Collections ```go rapid.SliceOf(rapid.Int()) rapid.SliceOfN(rapid.Int(), 1, 10) // min 1, max 10 elements rapid.MapOf(rapid.String(), rapid.Int()) ``` ### Combinators ```go rapid.OneOf(rapid.Int(), rapid.Int32()) // does not work for...

Details

Author
nWave-ai
Repository
nWave-ai/nWave
Created
3 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category