nw-pbt-go
FeaturedGo property-based testing with rapid and gopter frameworks
Testing & QA 636 stars
68 forks Updated today MIT
Install
Quality Score: 98/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
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
- 9 months ago
- Last Updated
- today
- Language
- Python
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Listed
pbt
Write property-based and metamorphic tests using rapid (pgregory.net/rapid) for Go. Triggers on: "property-based tests", "PBT", "rapid tests", "test with random inputs", "generative tests", "test properties", "randomized testing", "metamorphic testing", "metamorphic relations", and situations with no test oracle: expected outputs can't be written down, outputs legitimately vary between runs, or the code under test is concurrent/nondeterministic.
1 Updated 1 months ago
jeremiah-masters Testing & QA Featured
nw-pbt-rust
Rust property-based testing with proptest, quickcheck, and bolero frameworks
636 Updated today
nWave-ai Testing & QA Featured
nw-pbt-haskell
Haskell property-based testing with QuickCheck and Hedgehog frameworks
636 Updated today
nWave-ai