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