Published Sep 3, 2019

SE-Radio Episode 322: Bill Venners on Property Based Tests

Matthew Farwell and Bill Venners dive into the power of property-based testing, revealing how effective test shrinking and data generation techniques can streamline software development by identifying edge conditions and clarifying debugging processes.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Generator Basics

    Generators play a crucial role in property-based testing by producing the necessary data types for testing properties. explains that in languages like Haskell and Scala, generators are based on types, meaning they automatically produce data like doubles or integers based on the function's input type 1. This type-based generation ensures that the data aligns with the expected input, but custom types require custom generators. highlights the importance of matching generator types with target class types to avoid issues like generating invalid data 2.

    The type of your generator should match the type of your target class.

    ---

    This approach helps uncover unexpected issues in code, such as improper handling of null values.

       

    Structured Data

    Generating structured and context-dependent data presents unique challenges in property-based testing. describes how Scala's for expressions can be used to create generators for complex data types, like a person class with a name and age 3. These generators are concise but require careful composition to ensure all necessary data attributes are covered. However, points out the risk of combinatorial explosion, where not all data variations are tested due to the vastness of possible combinations 4.

    You're pretty much probably not going to explore the whole space.

    ---

    Despite these challenges, property-based testing remains a valuable tool for identifying edge cases and ensuring robust code.

Related Episodes