nw-pbt-dotnet
.NET property-based testing with FsCheck, CsCheck, and fsharp-hedgehog frameworks
Best use case
nw-pbt-dotnet is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
.NET property-based testing with FsCheck, CsCheck, and fsharp-hedgehog frameworks
Teams using nw-pbt-dotnet should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/nw-pbt-dotnet/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How nw-pbt-dotnet Compares
| Feature / Agent | nw-pbt-dotnet | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
.NET property-based testing with FsCheck, CsCheck, and fsharp-hedgehog frameworks
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# PBT .NET -- FsCheck + CsCheck (C#/F#)
## Framework Selection
| Framework | Language | Shrinking | Stateful | Parallel | Choose When |
|-----------|----------|-----------|----------|----------|-------------|
| FsCheck | C#/F# | Type-based | No | No | F#-first projects, or C# needing mature PBT |
| CsCheck | C# | PCG-based | Yes | Yes (linearizability) | C# projects needing concurrent testing |
| fsharp-hedgehog | F# | Integrated | No | No | F# projects wanting modern integrated shrinking |
**C# default**: CsCheck (better shrinking, stateful + parallel). **F# default**: FsCheck or fsharp-hedgehog.
## Quick Start (FsCheck)
```csharp
// C#
using FsCheck; using FsCheck.Xunit;
public class SortProperties
{
[Property]
public bool SortPreservesLength(List<int> xs) =>
xs.OrderBy(x => x).Count() == xs.Count;
}
```
```fsharp
// F#
open FsCheck
let propSortIdempotent (xs: int list) =
List.sort (List.sort xs) = List.sort xs
Check.Quick propSortIdempotent
```
## Generator Cheat Sheet (FsCheck)
### C#
```csharp
Arb.Generate<int>() // any int
Gen.Choose(0, 100) // bounded
Arb.Generate<string>()
Arb.Generate<List<int>>()
// Custom generator
public static Arbitrary<Email> EmailArb() =>
Arb.From(
from name in Arb.Generate<NonEmptyString>()
select new Email($"{name}@example.com")
);
Arb.Register<MyGenerators>(); // register custom arbitraries
```
### F#
```fsharp
Gen.choose (0, 100)
Gen.elements [1; 2; 3]
Gen.oneof [gen1; gen2]
Gen.frequency [(80, gen1); (20, gen2)]
Gen.listOf (Gen.choose (0, 100))
Gen.choose (0, 100) |> Gen.map (fun x -> x * 2)
gen {
let! xs = Gen.listOf (Gen.choose (0, 100))
let! x = Gen.elements xs
return (xs, x)
}
```
## Quick Start (CsCheck)
```csharp
using CsCheck;
[Fact]
public void Sort_Preserves_Length()
{
Gen.Int.Array
.Sample(arr => arr.OrderBy(x => x).Count() == arr.Length);
}
```
### CsCheck Generators
```csharp
Gen.Int // any int
Gen.Int[0, 100] // bounded
Gen.Double
Gen.String
Gen.Bool
Gen.Int.Array // int[]
Gen.Int.List // List<int>
Gen.Int.HashSet // HashSet<int>
Gen.Int.Select(x => x * 2) // map
Gen.Select(Gen.String, Gen.Int, (name, age) => new User(name, age))
Gen.OneOf(Gen.Int.Select(x => (object)x), Gen.String.Select(x => (object)x))
Gen.Int.Where(x => x > 0) // filter
```
## Stateful Testing
FsCheck: No stateful testing support. Use CsCheck for stateful and parallel testing.
fsharp-hedgehog: No stateful testing support.
### CsCheck Stateful Testing
```csharp
[Fact]
public void Store_Matches_Model()
{
Gen.Int.List[0, 100].Sample(operations =>
{
var store = new MyStore();
var model = new Dictionary<string, int>();
// CsCheck uses operation sequences with Check.Sample
});
}
```
### CsCheck Parallel/Linearizability Testing
```csharp
[Fact]
public void Store_Is_Linearizable()
{
Check.SampleConcurrent(
Gen.Operation<MyStore>(/* ... */),
initialState: () => new MyStore()
);
}
```
`Check.SampleConcurrent` runs operations sequentially then in parallel, checking against all possible linearizations. Shrinking works for parallel failures -- rare among PBT frameworks.
## Quick Start (fsharp-hedgehog)
```fsharp
open Hedgehog
let propReverse = property {
let! xs = Gen.list (Range.linear 0 100) Gen.alpha
return List.rev (List.rev xs) = xs
}
Property.check propReverse
```
### fsharp-hedgehog Generators
```fsharp
Gen.int (Range.linear 0 100)
Gen.string (Range.linear 0 50) Gen.alpha
Gen.bool
Gen.list (Range.linear 0 50) (Gen.int (Range.linear 0 100))
Gen.option (Gen.int (Range.linear 0 100))
```
## Test Runner Integration
```xml
<!-- FsCheck -->
<PackageReference Include="FsCheck.Xunit" Version="3.0.0" />
<!-- CsCheck -->
<PackageReference Include="CsCheck" Version="4.0.0" />
<!-- fsharp-hedgehog -->
<PackageReference Include="Hedgehog" Version="0.13.0" />
<PackageReference Include="Hedgehog.Xunit" Version="0.5.0" />
<!-- All work with xUnit, NUnit, MSTest (CsCheck/FsCheck) -->
```
## Unique Features
### FsCheck
- **F# + C# + VB.NET**: Works across all .NET languages
- **Arb<T> type class**: Type-based generation/shrinking, automatic derivation
- **v3 stable**: Major rewrite with improved API and performance
- **Conditional properties**: `Prop.When` for preconditions with automatic discard tracking
- **Model-based testing**: `Prop.ForAll` with `Command` for lightweight model checking
- **Observable properties**: Distribution analysis via `Prop.Collect` and `Prop.Classify`
### CsCheck
- **Parallel linearizability testing**: `Check.SampleConcurrent` -- rare capability
- **PCG-based shrinking**: Parallelizable, fast, reproducible
- **Performance testing**: Built-in `Check.Faster` for comparative benchmarks
- **Causal profiling**: Built-in `Check.CausalProfiling`
### fsharp-hedgehog
- **Computation expressions**: `gen { }`, `property { }` -- most readable F# PBT syntax
- **Integrated shrinking**: Automatic via rose trees
- **Hedgehog.Experimental**: Auto-generators (AutoFixture-like)Related Skills
nw-ux-web-patterns
Web UI design patterns for product owners. Load when designing web application interfaces, writing web-specific acceptance criteria, or evaluating responsive designs.
nw-ux-tui-patterns
Terminal UI and CLI design patterns for product owners. Load when designing command-line tools, interactive terminal applications, or writing CLI-specific acceptance criteria.
nw-ux-principles
Core UX principles for product owners. Load when evaluating interface designs, writing acceptance criteria with UX requirements, or reviewing wireframes and mockups.
nw-ux-emotional-design
Emotional design and delight patterns for product owners. Load when designing onboarding flows, empty states, first-run experiences, or evaluating the emotional quality of an interface.
nw-ux-desktop-patterns
Desktop application UI patterns for product owners. Load when designing native or cross-platform desktop applications, writing desktop-specific acceptance criteria, or evaluating panel layouts and keyboard workflows.
nw-user-story-mapping
User story mapping for backlog management and outcome-based prioritization. Load during Phase 2.5 (User Story Mapping) to produce story-map.md and prioritization.md.
nw-tr-review-criteria
Review dimensions and scoring for root cause analysis quality assessment
nw-tlaplus-verification
TLA+ formal verification for design correctness and PBT pipeline integration
nw-test-refactoring-catalog
Detailed refactoring mechanics with step-by-step procedures, and test code smell catalog with detection patterns and before/after examples
nw-test-organization-conventions
Test directory structure patterns by architecture style, language conventions, naming rules, and fixture placement. Decision tree for selecting test organization strategy.
nw-test-design-mandates
Four design mandates for acceptance tests - hexagonal boundary enforcement, business language abstraction, user journey completeness, walking skeleton strategy, and pure function extraction
nw-tdd-review-enforcement
Test design mandate enforcement, test budget validation, 5-phase TDD validation, and external validity checks for the software crafter reviewer