tdd in an iot world
play

TDD IN AN IoT WORLD Charles Korn 1 IoT? 2 What is TDD? 3 - PowerPoint PPT Presentation

TDD IN AN IoT WORLD Charles Korn 1 IoT? 2 What is TDD? 3 Test-driven development 4 Test-driven development Test-driven design 5 Its not just about testing your code 6 Its also about designing your code to be testable 7 CODE


  1. TDD IN AN IoT WORLD Charles Korn 1

  2. IoT? 2

  3. What is TDD? 3

  4. Test-driven development 4

  5. Test-driven development Test-driven design 5

  6. It’s not just about testing your code 6

  7. It’s also about designing your code to be testable 7

  8. CODE THAT IS DESIGNED TO BE EASY TO TEST Image credit: weedist.com 8

  9. Code that is easy to test is: small simple has a single responsibility 9

  10. Clean code is: small simple has a single responsibility 10

  11. But how? 11

  12. Red Green Refactor 12

  13. Image credits: unicornsrule.com and Nicolò Bertoncin 13

  14. Development environment 14

  15. ≈ ≈ ≉ Image credits: Michael Bundscherer, Kevin Kwok, Nicolò Bertoncin, R fl or 15

  16. Hardware constraints 16

  17. Long write-run-debug cycle 17

  18. 12 9 6 3 0 Host Target 18

  19. Might not have target hardware 19

  20. Development and production environment di ff erences Hardware constraints Long write-run-debug cycle Target hardware availability 20

  21. Red Green Test on Refactor target hardware Image credits: Kevin Kwok and Nicolò Bertoncin 21

  22. Compile Flash Run Compile Flash Run First 50% of tests Second 50% of tests 22

  23. Lots of low-level interactions with hardware 23

  24. Avoid direct interactions with hardware (or: use good abstractions) 24

  25. PINA |= (1 << LED_PIN) or turnOn(LED_PIN) expect(PINA & 0x04 == 1) or expect(getState(LED_PIN) == ON) 25

  26. Performance concerns 26

  27. Image credit: scmp.com 27

  28. IT’S A TRAP! Image credit: Lucas fi lm 28

  29. Know what ‘good enough’ looks like Know why it’s required Have a repeatable way to measure it The tests can help you 29

  30. C and C++ 30

  31. Image credit: memecenter.com 31

  32. Link-time fakes 32

  33. Function pointers 33

  34. Virtual classes 34

  35. Image credit: XKCD 35

  36. Go forth and TDD 36

  37. Before I go… 37

  38. 38

  39. 39

  40. https://github.com/charleskorn/stm32f4-project-template Image credit: blog.tkjelectronics.dk 40

  41. TDD for circuit design 41

  42. THANK YOU Charles Korn charleskorn.com

Recommend


More recommend