Property-based testing with clojure.spec

Clojure.spec was released recently in may 2016 and it was a perfect occasion to have Romeu speaking about Property-based Testing using clojure.spec.

The live coding session use the Bowling kata as a material, for those who wonder what that kata is here is a brief reminder:



Bowling Game Domain and Rules


The game consists of 10 frames as shown above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.

A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. ‘/’ denote a spare in the score sheet. A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. ‘X’ denote a striker in the score sheet.

In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame (so 3 balls can be rolled in tenth frame).

Video of the meetup session

Here is the video of the live coding session (in French):

The same talk in 45 mn with Java 6 and still about Property-based testing (in English)

The 3 hours version with some slide at Devoxx France (in French)

Traditional Solutions to the Kata

There is my own solution, the one from FlyingTof in this repo and the one from Jon and Thomas: thomas-and-john-solution.

Hiram made a great graphical version of the Bowling Kata with devcards.