Property-Based Test-Driven Development
Nat Pryce
Practitioner Workshop
Summary
A hands-on programming workshop to explore how property-based testing influences the TDD process & the designs it creates.
The TDD/BDD community has not embraced property-based testing, despite tools being available for most programming languages. TDD practitioners “triangulate” a property of the system by testing it against multiple examples, selected manually. Triangulation does not explicitly define the property being tested, giving little scope for automating the selection of test data. It is easy to write tests with poor condition/decision coverage. People reading a test must infer the property from the data and name of the test, which can be difficult.
The property-based testing literature has focused on testing for quality assurance. It does not describe property-based testing tools being used to drive development, focus attention, measure progress, and obtain design feedback. (Saff & Boshernitsan’s article on JUnit Theories is a notable exception).
We will investigate:
- How do we go from examples to properties? Must we start with examples and generalize to properties, or can we start with properties in some cases?
- How do we change properties as the system grows? Do we start with general properties and specialize them, or specialized properties and generalize? How does that compare to adding examples?
- Can property-based testing drive design? If we focus on properties, do we get different designs than if we focus on examples? Are some design styles easier than others to describe in terms of properties?
- Does property-based testing work better when working topdown/outsidein or bottomup/insideout?
You will need to bring a laptop with your favourite programming environment, a property-based testing library and, depending on the language, a test framework to run the property-based-tests. See also https://gist.github.com/npryce/4147916
Presenter
Nat Pryce is a co-author of Growing Object-Oriented Software Guided by Tests. An early adopter of XP, he has written or contributed to several open source libraries and tools that support TDD and was one of the founding organizers of the London XP Day conference. He has worked as a programmer, architect, trainer, and consultant in a variety of industries, including sports reportage, marketing communications, retail, media, telecoms and finance. He has delivered systems ranging from embedded devices to large compute farms supporting global business.