Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 2.7 KB

File metadata and controls

50 lines (33 loc) · 2.7 KB

How to write testable C++ for Arduino Arduino CI

How to write testable and reusable C++ for Arduino, following the Inversion of Control principle.

What?

This is the repository for the material included in the How to write testable C++ for Arduino video tutorial.

The tutorial demonstrates how to design and refactor C++ according to the Inversion of Control principle (IoC), using Arduino compatible code as an example. To follow along, it is advised you clone the repository and open it in an code editor.

Contents of interest

Homework

During the tutorial, you are tasked to complete the following tasks so to get hands-on practice with unit testing for Arduino:

  1. Finish the tests for the Calculator sketch.
  2. Finish the tests for the MagicCarControllerTestable sketch.

Once you are done, you can try evolving the code further and experimenting with the following stretch tasks:

  1. Write more unit tests to cover more edge cases.
  2. Inject the lightsPin instead of hard-coding it.
  3. Decouple the RestServer interface further from the ESP32 WebServer implementation and refactor the code as well as the tests accordingly.
  4. Think of a better way to return an Arduino String in a platform-agnostic way.

Solutions

The solutions can be found in the solutions branch.

Shared solutions

Do you have a solution that you want to share with us? Then fork this repository, push your solution to it and then let me know by opening an issue. I will add a link to your repo in this README file.