Improving design and code quality with property-based testing @ NLTestdag 2019

Improving design and code quality with property-based testing @ NLTestdag 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 or/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!

01abe62e641a626ed2dccc08ea2f8a14?s=128

Kenny Baas-Schwegler

November 20, 2019
Tweet

Transcript

  1. None
  2. 2 2 Strategic software delivery - Domain-Driven Design - Continuous

    Delivery - Socio-technical engineers - Collaborative modellers and facilitators
  3. None
  4. None
  5. 5

  6. None
  7. None
  8. 8

  9. Photo by chuttersnap on Unsplash

  10. 10

  11. 11

  12. Photo by Anton Shuvalov on Unsplash

  13. 13

  14. 14

  15. 15

  16. 16 Photo by Estée Janssens on Unsplash

  17. 17

  18. 18

  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
  20. 20

  21. 21

  22. 22 Photo by Patrick Lindenberg on Unsplash

  23. Photo by Samson on Unsplash

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

    Customer
  25. 25

  26. 26 Photo by david carballar on Unsplash

  27. 27 • • •

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

  29. 29

  30. 30

  31. 31

  32. Photo by Ilya Pavlov on Unsplash

  33. 33

  34. Photo by Ilya Pavlov on Unsplash

  35. None
  36. None
  37. 37 • • ◦ • • • Dave Farley -

    Continuous Delivery
  38. 38

  39. 39 • • •

  40. 40 • • • • •

  41. Strategic software delivery - Domain-Driven Design - Continuous Delivery -

    Socio-technical engineers - Collaborative modellers and facilitators