Property Test

Generate property-based tests with FsCheck or fast-check

majiayu000 Updated 567 repo stars

File contents

Property-Based Testing

Generate property-based tests that verify invariants across random inputs.

For .NET (FsCheck)

dotnet add package FsCheck.Xunit
[Property]
public Property Score_AlwaysBetween0And1(double[] weights)
{
    var score = MatchingService.CalculateScore(weights);
    return (score >= 0.0 && score <= 1.0).ToProperty();
}

For TypeScript (fast-check)

npm install --save-dev fast-check
fc.assert(fc.property(fc.array(fc.double()), (weights) => {
  const score = calculateScore(weights);
  return score >= 0 && score <= 1;
}));

Arguments

  • <target-class>: Class or module to test
  • --framework=<fscheck|fast-check>: Testing framework

majiayu000/claude-skill-registry-data/tree/main/testing/property-test commit 0dd92b5b2d

Frequently asked questions

npx skillmds@latest add majiayu000/property-test