Slide 1

Slide 1 text

Improving design and code quality with Property-based testing

Slide 2

Slide 2 text

2 Strategic Technology Consultants - Agile Technical Coaches - Domain-Driven Design - Continuous Delivery - EventStorming - Example Mapping @kenny_baas baasie.com @joaoasrosa joaorosa.io

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

5 @kenny_baas @joaoasrosa @kenny_baas @joaoasrosa

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

8 @kenny_baas @joaoasrosa

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

10 @kenny_baas @joaoasrosa

Slide 11

Slide 11 text

11 @kenny_baas @joaoasrosa The greatest obstacle to discovery is not ignorance - it is the illusion of knowledge. - Daniel J. Boorstin

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

13 @kenny_baas @joaoasrosa

Slide 14

Slide 14 text

14 @kenny_baas @joaoasrosa

Slide 15

Slide 15 text

15 @kenny_baas @joaoasrosa

Slide 16

Slide 16 text

16 @kenny_baas @joaoasrosa Testing should be about: Learning from mistakes instead of only confirming

Slide 17

Slide 17 text

17 @kenny_baas @joaoasrosa

Slide 18

Slide 18 text

18 @kenny_baas @joaoasrosa

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

20 @kenny_baas @joaoasrosa

Slide 21

Slide 21 text

21 @kenny_baas @joaoasrosa To communicate effectively, the code must be based on the same language used to write the requirements - the same language that the developers speak with each other and with domain experts - Eric Evans

Slide 22

Slide 22 text

22 @kenny_baas @joaoasrosa Testing should be about: Living documentation on behaviour instead of on data

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

24 @kenny_baas @joaoasrosa Dave Farley - Continuous Delivery Feedback Quickly Timely Reliable Customer

Slide 25

Slide 25 text

25 @kenny_baas @joaoasrosa Releasing software is too often an art; it should be an engineering discipline - Dave Farley

Slide 26

Slide 26 text

26 @kenny_baas @joaoasrosa Testing should be about: Fast feedback on new demands instead of slow changes

Slide 27

Slide 27 text

27 @kenny_baas @joaoasrosa Single abstraction examples (aka Unit tests) ● Learning from mistakes instead of only confirming ● Fast feedback on new demands instead of slow changes ● Living documentation on behaviour instead of on data

Slide 28

Slide 28 text

28 @kenny_baas @joaoasrosa In comes Property-based testing The construction of tests such that, when these tests are fuzzed, failures in the test reveal problems with the system under test

Slide 29

Slide 29 text

29 @kenny_baas @joaoasrosa Fuzzing in Property-based testing Randomly generate data points within the boundary of a business invariant to verify the behaviour of the system

Slide 30

Slide 30 text

30 @kenny_baas @joaoasrosa Frameworks: Java Junit4: JUnit-Quickcheck Java JUnit5: jqwik C#: FsCheck

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

32 @kenny_baas @joaoasrosa

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

35 @kenny_baas @joaoasrosa Human CI ● Always run tests locally before commiting ● Once the code is committed, wait for the result of commited build ○ Don’t go home, to lunch, to a meeting, to make coffee ● If a teammate has gone home, lunch…. revert their changes! ● Fix or revert within 10 minutes ● When there are failures, Pair or Mob and learn together Dave Farley - Continuous Delivery

Slide 36

Slide 36 text

36 @kenny_baas @joaoasrosa Software Development is a learning process, working code is a side effect - Alberto Brandolini

Slide 37

Slide 37 text

37 @kenny_baas @joaoasrosa Benefits ● Covers (eventually) the scope of all data points, forget about data ● Shrinker looks for a small use case ● Reproducible tests Next thing -> Fuzzing invalid inputs in System Tests

Slide 38

Slide 38 text

38 @kenny_baas @joaoasrosa Summary ● (Also) Write tests with the intention of breaking code ● Forget about data, focus on behaviour! ● Quickly, Timely, Reliable Feedback ● Human CI ● Ohh… Have we mentioned Domain-Driven Design?

Slide 39

Slide 39 text

39 @kenny_baas @joaoasrosa C# https://github.com/joaoasrosa/techorama-nl-property-based-testing Java https://gitlab.com/Baasie/Property-Based-Testing

Slide 40

Slide 40 text

#CatTax