“THE SHAPES” — THE PYRAMID
e2e
integration
unit
https://web.dev/articles/ta-strategies
Slide 15
“THE SHAPES” — THE PYRAMID
more integrated
e2e
integration
more isolated
unit
https://web.dev/articles/ta-strategies
Slide 16
“THE SHAPES” — THE PYRAMID
slower & more expensive
e2e
integration
faster & cheaper
unit
https://web.dev/articles/ta-strategies
Slide 17
“THE SHAPES” — THE ICE CONE
e2e
integration
unit
https://web.dev/articles/ta-strategies
Slide 18
“THE SHAPES” — THE CRAB
🦀
e2e
integration & unit tests https://web.dev/articles/ta-strategies
Slide 19
“THE SHAPES” — THE DIAMOND
e2e
integration
unit
https://web.dev/articles/ta-strategies
Slide 20
“THE SHAPES” — THE DIAMOND
e2e
integration
unit
https://web.dev/articles/ta-strategies
Slide 21
“THE SHAPES” — THE HONEYCOMB
e2e
integration
unit
https://web.dev/articles/ta-strategies
Slide 22
WE ARE ABLE TO REFACTOR THE INTERNALS WITHOUT TOUCHING ANY TESTS. WE COULD EVEN REPLACE THE DATABASE FROM POSTGRESQL TO NOSQL WITHOUT HAVING TO MODIFY THE ACTUAL TEST METHODS.
https://engineering.atspotify.com/2018/01/testing-of-microservices/
Slide 23
THE TRADE-OFF HERE IS SOME LOSS OF SPEED IN TEST EXECUTION [… AND …] THAT WE MIGHT LOSE SOME FEEDBACK ACCURACY WHEN A TEST FAILS
https://engineering.atspotify.com/2018/01/testing-of-microservices/
Slide 24
“THE SHAPES” — THE TROPHY
e2e
integration
unit static
https://web.dev/articles/ta-strategies
WHY DO WE NOT WRITE TESTS?
“We don’t have time for this”
Slide 31
WHY DO WE NOT WRITE TESTS?
“We don’t have time for this” “They start failing when changing unrelated code or implementation details and are becoming brittle quickly”
Slide 32
WHY DO WE DO WRITE TESTS?
Slide 33
WHY DO WE DO WRITE TESTS?
“To make our managers or team lead happy”
Slide 34
ANY OBSERVED STATISTICAL REGULARITY WILL TEND TO COLLAPSE ONCE PRESSURE IS PLACED UPON IT FOR CONTROL PURPOSES — Goodhart’s Law
https://www.ribbonfarm.com/2016/06/09/goodharts-law-and-why-measurement-is-hard/
Slide 35
WHY DO WE DO WRITE TESTS?
“To make our managers or team lead happy”
Slide 36
WHY DO WE DO WRITE TESTS?
“To make our managers or team lead happy” Stability for the end-user
Slide 37
“A MAJORITY OF THE PRODUCTION FAILURES (77%) CAN BE REPRODUCED BY A UNIT TEST.” — Simple testing can prevent most critical failures; Research paper from the University of Toronto (2014)
https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-yuan.pdf
Slide 38
WHY DO WE DO WRITE TESTS?
“To make our managers or team lead happy” Stability for the end-user Enable refactoring
Slide 39
CODE IS READ AND UPDATED WAY MORE OFTEN THAN IT IS WRITTEN — Tim Bray
https://www.tbray.org/ongoing/When/202x/2021/05/15/Testing-in-2021
Slide 40
“WALKING ON WATER AND DEVELOPING SOFTWARE FROM A SPECIFICATION ARE EASY IF BOTH ARE FROZEN” — Edward V. Berard
https://en.wikiquote.org/wiki/Edward_V._Berar
Slide 41
PART III:
a little d etour, sorry!
TDD — The misunderstood monster under your bed
Slide 42
RED-GREEN-REFACTOR
Slide 43
RED-GREEN-REFACTOR
Write a test that describes the desired behaviour
https://tidyfirst.substack.com/p/canon-tdd
Slide 44
RED-GREEN-REFACTOR
Write a test that describes the desired behaviour Write the minimal amount of code necessary to make the test pass
https://tidyfirst.substack.com/p/canon-tdd
Slide 45
RED-GREEN-REFACTOR
Write a test that describes the desired behaviour Write the minimal amount of code necessary to make the test pass Refactor the code https://tidyfirst.substack.com/p/canon-tdd
Slide 46
SELF-TESTING CODE
Slide 47
Slide 48
SELF-TESTING CODE
Tests should be part of your code delivery
https://martinfowler.com/distributedComputing/duckling.pdf
Slide 49
SELF-TESTING CODE
Tests should be part of your code delivery You should be running tests as often as possible — ideally automated
https://martinfowler.com/distributedComputing/duckling.pdf
Slide 50
TDD — SOME MISCONCEPTIONS
Slide 51
TDD — SOME MISCONCEPTIONS
“TDD means I have to write my tests first!”
Slide 52
IS TDD DEAD? — VIDEO SERIES WITH DHH, MARTIN FOWLER AND KENT BECK
https://martinfowler.com/articles/is-tdd-dead/
Slide 53
TDD — SOME MISCONCEPTIONS
“TDD says I have to mock everything outside of the unit test scope”
Slide 54
“SIMILARLY THEIR NOTION OF INTEGRATION TEST SOUNDS VERY MUCH LIKE WHAT I WOULD CALL A SOCIABLE UNIT TEST. THIS MAKES THE PYRAMID VERSUS HONEYCOMB DISCUSSION MOOT” — Martin Fowler
https://martinfowler.com/articles/2021-test-shapes.html
Slide 55
Slide 56
PART IV: Practical tips to get started with testing
Slide 57
1
Be the advocate!
Slide 58
2
Embrace tests as a way to improve developer confidence
Slide 59
3
Test behaviour, not implementation details
Slide 60
4
Automate your tests!
Slide 61
5
Identify the most common or likely points of failure in your system
Slide 62
ANOTHER APPLICATION OF CYCLOMATIC COMPLEXITY IS IN DETERMINING THE NUMBER OF TEST CASES THAT ARE NECESSARY TO ACHIEVE THOROUGH TEST COVERAGE OF A PARTICULAR MODULE.
https://en.wikipedia.org/wiki/Cyclomatic_complexity
Slide 63
6
Don’t just blindly follow a “shape” or strategy
Slide 64
ENSURE YOUR “SHAPE” HAS INTENTION
Slide 65
ENSURE YOUR “SHAPE” HAS INTENTION
let’s add the static la yer
Slide 66
ENSURE YOUR “SHAPE” HAS INTENTION
m e t s y s eco e m o s s r e v o c s t s te
Slide 67
ENSURE YOUR “SHAPE” HAS INTENTION
m e t s y s eco e m o s s r e v o c s t s te
other “natur al” erosio n
Slide 68
7
Have smaller milestones to work towards the end goal
Slide 69
MILESTONES TO YOUR IDEAL SETUP
manual testing
Slide 70
MILESTONES TO YOUR IDEAL SETUP
quick & easy confid ence boost
Slide 71
MILESTONES TO YOUR IDEAL SETUP
p u g n i d l i e r bu o c e h t
Slide 72
MILESTONES TO YOUR IDEAL SETUP
Slide 73
THE END. @jburr90 / Julian Burr
https://www.julianburr.de/ ddd-melbourne-2024-slides.pdf