.. include:: 2026-10-27 (3VO): Unit Testing, Project Kickoff =============================================== Unit Testing ------------ * :doc:`/trainings/material/soup/misc/unittest/unittest_gtest_basics/screenplay` Project Talk ------------ .. topic:: Exercise: Temperature Display What we are doing here is very similar to :ref:`fh-2026-06-03-exercise`. Door .... * Paradigm: polling Every ``n`` time units we look at switch states, and react accordingly. Hypothetical main program will look like follows. *This is only a goal!* We start with unit tests, and there won't be a main program initially. .. code-block:: c++ FSM fsm(open_switch, closed_switch, dwim_switch, motor); while (true) { fsm.check(); sleep(1ms); } * FSM, as sketched :ref:`here ` * Constructor, and ``check()`` method as envisioned above * Hardware independent * *Defines interfaces*, a task not to be taken lightly * Input switch * Motor * First stage: test coverage of all transitions; mock implementations of interfaces as needed by unit tests * Input switch (reading state from file) * Interface ideally as defined by FSM. We are starting in parallel with FSM, so interfaces not yet stable/available |longrightarrow| Meeting with FSM group to setup common viewpoint. * First "real" implementation (as opposed to lightweight mock used by FSM team): read switch state from file * Motor (writing state to file) * Interface ideally as defined by FSM. We are starting in parallel with FSM, so interfaces not yet stable/available |longrightarrow| Meeting with FSM group to setup common viewpoint. * First "real" implementation (as opposed to lightweight mock used by FSM team): write motor state to file ("idle", "forward", "backward") * Integration |longrightarrow| Firmware At some point we want to create a fake door firmware where the poor manual tester ... * writes ones and zeroes into switch files * checks the motor file to see if everything is alright