The importance of automated testing.
I’ve been working on a number of core Simple IoT improvements lately and trying to get some end-to-end testing going. A few realizations:
- globals are really bad. Never assume any module will be a singleton.
- every thread needs lifecycle management including a stop function that initiates a controlled shutdown. Never assume a thread will run forever, because then it is not testable.
- your entire app should have lifecycle management such that it can be started in a unit test and shut down cleanly.
- ideally, there is no difference between unit and e2e testing – same framework, tools.
This is an interesting approach to make your main() function runnable:
This already mentioned article has some good ideas as well.