Skip to content

"A taste of Property Based Testing" and Kata hack!

Photo of Tim Cooke
Hosted By
Tim C. and Steven H.
"A taste of Property Based Testing" and Kata hack!

Details

The Lightening talk

"A taste of Property Based Testing" by Garth Gilmour

Agile methods like TDD and BDD enable you to continuously verify the choices made during your design, ensuring that neither extension nor refactoring introduces errors. Today a comprehensive, fully automated unit test suite is taken as a prerequisite for code quality. But regardless of how good such test suites become they cannot discover the 'unknown unknowns', that is the corner cases that no one knows about because no one thinks to look for.

Property based testing is a functional style of testing that compliments existing approaches. The tester specifies statements about their solution that should always be true (e.g. an uppercased string contains no lowercase letters) and these properties are then verified against randomly generated data sets. Because the data sets are randomly produced (via Generator objects) the edge cases in your solution will eventually be revealed.

This lightning talk will introduce Property Based Testing in general and then run through a simple case study using the 'Scalacheck' framework. Similar frameworks available for other languages will also be mentioned.

Garth Gilmour gave up full time development back in 1999 to teach and mentor full time. Since then he's delivered over a thousand courses and workshops to all kinds of coders from all kinds of places. After a decade of flying solo he came to roost as 'Head of Learning' at Instil. When not at the whiteboard he coaches Krav Maga and fights nerf wars with his kids. Occasionally someone asks him if he ever does any real work, but to date none of the bodies have been found.

------

The Kata

It's a classic that's been done thousands of times over but this time there's a twist. We want you to show off your functional programming testing skills.

99 Bottles of beer (99-bottles-of-beer.net (http://99-bottles-of-beer.net/))

Write a program that generates the following song lyrics:

99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.

98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

...

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.

No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.

Photo of Belfast FP group
Belfast FP
See more events
Instil Software
7 James St S, Belfast, Antrim BT2 8DN · Belfast