Property Testing: Finding More Bugs With Less Effort?
Testing is an essential part of writing and maintaining correct and reliable software. However, for the most part the best technique we have for writing tests is to capture some examples in the hope that they cover all the known edge cases. Unfortunately these examples almost always missing something.
What if we could ask the computer to generate these examples? Not just a handful, but hundreds of them that we never even considered. It turns out we can! By using the technique known as Property Based Testing.
This talk will explore the motivation and concepts behind this powerful testing technique. We also introduce a number of simple but useful patterns that can be applied again and again when writing properties. In addition this talk will highlight a handful of compelling examples of Property Based Testing uncovering nasty bugs in real world software.
Finally, apart from learning about why and how to use Property Based Testing to write better software, the audience will also realise that testing can be made more enjoyable in the process.
A problem with pattern matching in monadic code
Sometimes Scala code with for comprehensions fail to compile with the confusing error "could not find implicit value for parameter M: scalaz.Monoid[Error]", but it's not immediately clear why, or why it does work when we replace Either/Disjunction with Option.
I'll discuss why this occurs, a simple fix to make it work, and compare with similar situations in other languages with pattern-matching and monads (Haskell, Idris, Purescript), ending by identifying a Scala feature that perhaps could be improved in future compiler versions.