Slide 1

Slide 1 text

Lunch & Learn Property based Testing

Slide 2

Slide 2 text

What is a Property? Something always true in a given context

Slide 3

Slide 3 text

Could be Strong The total is the sum of the elements The answer is always 42 …

Slide 4

Slide 4 text

But most of the time, it’s weak The appointment is always in the future The invoice is never negative …

Slide 5

Slide 5 text

A test only validate one specific case

Slide 6

Slide 6 text

Wait, we also have parameterized tests

Slide 7

Slide 7 text

Yes but we go further with random generators

Slide 8

Slide 8 text

Let me introduce FsCheck A port of Haskell’s Quickcheck for .NET

Slide 9

Slide 9 text

Generator: easily generates a number of random values for many types Shrinker: tries to find the mininal counter example that still fails the property

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Property based testing don’t replace unit testing

Slide 12

Slide 12 text

Property based testing test a lot of random cases cheaply

Slide 13

Slide 13 text

Random??? So what does green mean? Testing show the presence, not the absence of bug E. W. Dijktra

Slide 14

Slide 14 text

Finding good properties is hard

Slide 15

Slide 15 text

But it is worth to think about general properties of your business

Slide 16

Slide 16 text

Thanks QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs http://www.cs.tufts.edu/~nr/cs257/archive/john-hughes/quick.pdf An introduction to property-based testing http://fsharpforfunandprofit.com/posts/property-based-testing/ FsCheck https://fscheck.github.io/FsCheck/