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

Improving design and code quality with Property...

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. 2 2 Strategic software delivery - Domain-Driven Design - Continuous

    Delivery - Socio-technical engineers - Collaborative modellers and facilitators
  2. 5

  3. 8

  4. 10

  5. 11

  6. 13

  7. 14

  8. 15

  9. 17

  10. 18

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

  13. 21

  14. 25

  15. 29

  16. 30

  17. 31

  18. 33

  19. 38

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

    Socio-technical engineers - Collaborative modellers and facilitators