Property-Based Testing for Better Code

Property-Based Testing for Better Code

Friday, 3:00pm - 3:50pm

Have you ever been stymied in your refactoring by all the test cases you'd have to update? Or read a test and thought, "But WHY that particular result?" Or been bitten in production by a corner case? It always seems like there are too many tests, too few, or both.


Functional thinking to the rescue! In FP, we like to figure out what our code does in all circumstances, not only a few. The verification side of this is Property-Based Testing, and the framework is ScalaCheck.


Come learn the charm of autogenerated test data, the beauty of expressing only what matters, and the challenge of stating what you need without repeating the code under test. Property-based testing isn't only for more tests with less code. It's about constraining your implementation in all the ways that matter and fewer of the ways that don't. These tests can help your software evolve: maximize correctness without hindering flexibility. When 1 test is 100 tests, the number is always just right.

Jessica.Kerr's picture
For more than a dozen years, Jessica Kerr toiled at enterprise software in Java and C. Two years ago, the promise and intrigue of functional programming led her to Scala. When she isn't speaking about at development conferences in North America and Europe, she works in Clojure at Outpace. In between, she edits Scala books for Artima, teaches workshops about git, and entertains two young daughters. Find her thoughts @jessitron or blog.jessiton.com