Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Improving design and code quality with Property-based testing @ TestDag Utrecht 2019

João Rosa
November 20, 2019

Improving design and code quality with Property-based testing @ TestDag Utrecht 2019

A suite of traditional unit tests will only be as strong as the possible arguments or parameters tested against your code. Quoting Romeu Moura: If you take a String as an argument, then the works of Shakespeare in Japanese & Korean are ONE valid input. Obviously, this can be achieved with parameterized testing. However, this makes the unit tests so big that it is harder to understand which behaviour it is validating. We want our unit tests to also serve as living documentation so they should be comprehensible and to the point.

Enter Property-Based Testing. In Property-Based Testing, we randomly generate data points within the boundary of a property to verify the property’s behaviour. This not only lets us test edge cases that could expose unwanted and unexpected errors in the code but also enables us to make small tests that are readable and clear. Making these tests will also force you to think harder about the problem at hand and improve your design and code quality.

In this technical session, Kenny & João demonstrates and explains what property-based testing is, and how to implement it in C# with FsCheck and Java with JUnit-Quickcheck. If you are interested in improving your unit testing, so you don’t have to worry much about test data anymore, but more about the problem your code is solving, this talk is for you!

João Rosa

November 20, 2019
Tweet

More Decks by João Rosa

Other Decks in Technology

Transcript

  1. View Slide

  2. 2
    2
    Strategic software delivery -
    Domain-Driven Design -
    Continuous Delivery -
    Socio-technical engineers -
    Collaborative modellers and
    facilitators

    View Slide

  3. View Slide

  4. View Slide

  5. 5

    View Slide

  6. View Slide

  7. View Slide

  8. 8

    View Slide

  9. Photo by chuttersnap on Unsplash

    View Slide

  10. 10

    View Slide

  11. 11

    View Slide

  12. Photo by Anton Shuvalov on Unsplash

    View Slide

  13. 13

    View Slide

  14. 14

    View Slide

  15. 15

    View Slide

  16. 16
    Photo by Estée Janssens on Unsplash

    View Slide

  17. 17

    View Slide

  18. 18

    View Slide

  19. blue yellow yellow red green purple blue blue green purple yellow
    red green yellow purple blue red yellow green red blue purple
    yellow purple red blue purple blue green yellow red red purple
    green yellow blue blue yellow green red purple yellow blue green
    red purple yellow red blue green purple green red yellow purple
    blue purple green red blue yellow yellow red green purple blue blue
    green purple yellow red green yellow purple blue red yellow green
    red blue purple yellow purple red blue green red purple yellow blue
    green red purple yellow red blue green purple green red yellow
    purple blue purple green red blue yellow yellow red green purple
    blue blue green purple yellow red green yellow purple blue red
    yellow green red blue purple yellow purple red blue green red
    purple yellow blue green red purple yellow red blue green purple
    green red yellow purple blue purple green red blue yellow yellow

    View Slide

  20. 20

    View Slide

  21. 21

    View Slide

  22. 22
    Photo by Patrick Lindenberg on Unsplash

    View Slide

  23. Photo by Samson on Unsplash

    View Slide

  24. 24
    Dave Farley - Continuous Delivery
    Feedback
    Quickly
    Timely
    Reliable
    Customer

    View Slide

  25. 25

    View Slide

  26. 26
    Photo by david carballar on Unsplash

    View Slide

  27. 27



    View Slide

  28. 28
    Transcript from FFS Conf - https://docs.google.com/document/d/e/2PACX-1vRS232prL-Bq44hmmdzJTHkCz-nYBlQVPAtemOmVfDP1rbiD777jQAaUpIeF2KCdSSEJMEwHTeo9QdE/pub

    View Slide

  29. 29

    View Slide

  30. 30

    View Slide

  31. 31

    View Slide

  32. Photo by Ilya Pavlov on Unsplash

    View Slide

  33. 33

    View Slide

  34. Photo by Ilya Pavlov on Unsplash

    View Slide

  35. View Slide

  36. View Slide

  37. 37






    Dave Farley - Continuous Delivery

    View Slide

  38. 38

    View Slide

  39. 39



    View Slide

  40. 40





    View Slide

  41. Strategic software delivery -
    Domain-Driven Design -
    Continuous Delivery -
    Socio-technical engineers -
    Collaborative modellers and facilitators

    View Slide