9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a...
Transcript of 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a...
![Page 1: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/1.jpg)
Nordic Testing Days
9 ways to test your spaghetti code
Mads Opheim @MadsOpheim
1
![Page 2: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/2.jpg)
Tere!
I’m Mads.I’m a developer
2
![Page 3: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/3.jpg)
Spaghetticode?
3
![Page 4: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/4.jpg)
The 9 ways
4
![Page 5: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/5.jpg)
5
1. Test allorTest small
![Page 6: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/6.jpg)
6
2. Set your dependencies
![Page 7: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/7.jpg)
7
![Page 8: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/8.jpg)
Singletons
8
![Page 9: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/9.jpg)
3. Package-protect problematic parts
9
![Page 10: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/10.jpg)
Tools for your toolbox
10
![Page 11: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/11.jpg)
4. Do simple refactorings toget your code under test
11
![Page 12: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/12.jpg)
In general: untangling and looking at one part at a time
12
![Page 13: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/13.jpg)
You’re not as smart as you think you are
13
![Page 14: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/14.jpg)
Well-designed code is testable code
14
![Page 15: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/15.jpg)
15
5. Help your team
![Page 16: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/16.jpg)
You’ll forget things
16
![Page 17: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/17.jpg)
6. Run your tests - and care
17
![Page 18: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/18.jpg)
7. Feature toggles
18
![Page 19: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/19.jpg)
8. One mile at a time
19
![Page 20: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/20.jpg)
Refactor in separate commits
20
![Page 21: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/21.jpg)
9. Test-driven development
21
![Page 22: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/22.jpg)
Test-driven spaghetti
22
![Page 23: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/23.jpg)
TDD on legacy code in practice
23
![Page 24: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/24.jpg)
Tip 10, 11 and onwards
24
![Page 25: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/25.jpg)
25
The Deadline For Kunngjøring Is Four Weeks()
![Page 26: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/26.jpg)
26
Properties For Namsmann Mainly Follow The Same Rules as Hovedstevnevitne()
![Page 27: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/27.jpg)
You’ll do stupid things - and that’s ok
27
![Page 28: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/28.jpg)
Be consistent
28
![Page 29: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/29.jpg)
Give me more@lisacrispin, @lisihocke, @techgirl1908,@maaretp...
29
![Page 30: 9 ways to test your spaghetti code - Nordic Testing Days · Feature toggles 18. 8. One mile at a time 19. Refactor in separate commits 20. 9. Test-driven development 21. Test-driven](https://reader034.fdocuments.in/reader034/viewer/2022042410/5f28a298b2c98130352df65e/html5/thumbnails/30.jpg)
Key takeaways
30
1. Good code design improves testability2. TDD on spaghetti code: TDD + test
spaghetti code3. Write tests for you legacy code -
you can do it!