Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Property-based testing

jub0bs
September 02, 2016

Property-based testing

Talk given at Bordeaux's Functional-Programming meetup group.

(See https://www.meetup.com/bdx-fp/events/233327084/)

jub0bs

September 02, 2016
Tweet

More Decks by jub0bs

Other Decks in Programming

Transcript

  1. Gluttony • too many test cases for the same behaviour

    • bloated test suite • tedious to write, read, maintain
  2. Greed • slave to code-coverage metrics • Low code coverage

    indicates inadequate testing, but high code coverage guarantees nothing.
  3. Sloth • The lights are on, but no one’s home.

    • Test cases are too few. • Test cases lack imagination, miss edge cases.
  4. Wrath • Tests that written with their role as executable

    specifications in mind • However, only the concrete scenario that follows is executable! • Scenarios cannot lay claim to completeness. • Leaves reader to infer actual general behaviour from tests • Sometimes leads to wrong assumptions about behaviour! • Lack empathy and expressiveness
  5. Envy • The size of the test suite is fixed.

    • A bigger test suite requires writing more test cases.
  6. Pride • Frivolous / noisy data • Fun at the

    beginning, but distracting…
  7. Greed • Less focus on code-coverage metrics • Rich properties

    and generators will give you high code- coverage. • "For all input values allowed by the compiler, does the implementation fulfill the API’s contract?”
  8. Sloth • Leave the tedium to the library. • Less

    typing; more thinking. • Reason about the actual behaviour of your code… • … at a higher level of abstraction.
  9. Wrath • Reason about the actual behaviour of your code…

    • … at a higher level of abstraction. • Tell the reader of your code.
  10. Libraries • Haskell: QuickCheck • Erlang: QuickCheck • Java: junit-quickcheck

    • Scala: ScalaCheck • Python: HypothesisWorks/hypothesis-python • etc…
  11. Talks • Practical Property-Based Testing - Charles O’Farrell • Testing

    the Hard Stuff and Staying Sane - John Hughes • Property-Based Testing, enfin pour tout le monde - Cyrille Martraire & Romeu Moura