FsCheck is a .NET library for property-based testing. Instead of checking one known input and expected result, you describe properties or behaviors that should always hold. section 14.5.2
FsCheck generates randomly distributed inputs, beginning with simple values and increasing their length, complexity, and character variety. This explores thousands of cases where one-off unit tests might provide limited confidence. section 14.5.2
Use FsCheck when:
- Standard unit tests do not cover a sufficiently large or varied input space. section 14.5.2
- Several related properties together describe the required relationship between a function's input and output. section 14.5.2
- You can invest more effort in tests to gain greater confidence in correctness. section 14.5.2
Testing flipCase
A conventional test might call flipCase with "Hello" and check one expected result. An FsCheck test instead states properties governing the relationship between any input string and its output, then checks those properties across progressively more complex strings. section 14.5.2
Compare a single explicit input and expected output with property-based exploration. section 14.5.2
Figure 14.3 Testing a function by proving that for any given input, it exhibits a set of rules or properties that govern the relationship between the input and output
Explore how rules about input-output relationships replace a fixed expected result. section 14.5.2
