{"id":16692672,"url":"https://github.com/platisd/reusable-testable-arduino-tutorial","last_synced_at":"2026-04-02T14:59:53.181Z","repository":{"id":51949463,"uuid":"275117208","full_name":"platisd/reusable-testable-arduino-tutorial","owner":"platisd","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-08T21:03:57.000Z","size":1038,"stargazers_count":15,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T01:14:59.213Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/platisd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-26T09:16:41.000Z","updated_at":"2024-08-03T09:29:13.000Z","dependencies_parsed_at":"2022-08-23T23:01:04.551Z","dependency_job_id":null,"html_url":"https://github.com/platisd/reusable-testable-arduino-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Freusable-testable-arduino-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Freusable-testable-arduino-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Freusable-testable-arduino-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platisd%2Freusable-testable-arduino-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/platisd","download_url":"https://codeload.github.com/platisd/reusable-testable-arduino-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137891,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T16:28:04.256Z","updated_at":"2026-04-02T14:59:53.132Z","avatar_url":"https://github.com/platisd.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to write testable C++ for Arduino ![Arduino CI]\n\nHow to write testable and reusable C++ for Arduino, following the\n[Inversion of Control principle](https://en.wikipedia.org/wiki/Inversion_of_control).\n\n\u003ca href=\"https://youtu.be/jCLgqaXS6Gg\"\u003e\u003cimg src=\"https://i.imgur.com/awxkHQV.png\" width=\"500\"\u003e\u003c/a\u003e\n\n[Arduino CI]: https://github.com/platisd/reusable-testable-arduino-tutorial/workflows/Arduino%20CI/badge.svg?branch=master\n\n## What?\n\nThis is the repository for the material included in the\n[How to write testable C++ for Arduino](https://youtu.be/jCLgqaXS6Gg) video tutorial.\n\nThe tutorial demonstrates how to design and refactor C++ according to the **Inversion of Control**\nprinciple (IoC), using Arduino compatible code as an example. To follow along, it is advised you\n`clone` the repository and open it in an code editor.\n\n### Contents of interest\n* Calculator [resources](sketches/calculator) and [test](test/ut/calculator_test.cpp)\n* MagicCarController [sketch](sketches/MagicCarController/MagicCarController.ino)\n* MagicCarControllerTestable [resources](sketches/MagicCarControllerTestable) and [test](test/ut/MagicCarController_test.cpp)\n\n## Homework\n\nDuring the tutorial, you are tasked to complete the following tasks so to get hands-on practice with\nunit testing for Arduino:\n\n1. Finish the tests for the [Calculator sketch](sketches/calculator/calculator.ino).\n2. Finish the tests for the [MagicCarControllerTestable sketch](sketches/MagicCarControllerTestable/MagicCarControllerTestable.ino).\n\nOnce you are done, you can try evolving the code further and experimenting with the following stretch\ntasks:\n\n1. Write more unit tests to cover more edge cases.\n2. Inject the [lightsPin](https://github.com/platisd/reusable-testable-arduino-tutorial/blob/master/sketches/MagicCarControllerTestable/MagicCarController.cpp#L11) instead of hard-coding it.\n3. Decouple the [RestServer](https://github.com/platisd/reusable-testable-arduino-tutorial/blob/master/sketches/MagicCarControllerTestable/RestServer.h) interface further from the ESP32 `WebServer` implementation and refactor the code as well as the tests accordingly.\n4. Think of a better way to return an Arduino `String` in a platform-agnostic way.\n\n### Solutions\n\nThe solutions can be found in the [solutions](https://github.com/platisd/reusable-testable-arduino-tutorial/tree/solutions) branch.\n\n#### Shared solutions\n\nDo you have a solution that you want to share with us? Then fork this repository, push your solution to it\nand then let me know by opening an issue. I will add a link to your repo in this `README` file.\n\n* [Platform-agnostic strings](https://github.com/PascalGuenther/reusable-testable-arduino-tutorial/tree/solutions)\nby [PascalGuenther](https://github.com/PascalGuenther)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatisd%2Freusable-testable-arduino-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplatisd%2Freusable-testable-arduino-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatisd%2Freusable-testable-arduino-tutorial/lists"}