jamesmunns / pretty-hal-machine

Apache License 2.0
59 stars 7 forks source link

Add integration tests with `embedded-hal-mock` and `insta` #12

Open jamesmunns opened 2 years ago

jamesmunns commented 2 years ago

We can use the embedded-hal-mock crate to implement a Machine worker that will allow us to verify the behavior in CI testing.

Additionally, we can add insta tests to snapshot the messages-on-the-wire to ensure we never accidentally break the wire protocol.

At the moment, we have a hard dependency on serialport::SerialPort, HOWEVER, this is a Box<dyn SerialPort> object, and it would be totally possible to mock this as well instead of using a real serial port.

End to end, this would look a little something like this:

jamesmunns commented 2 years ago

Oh, also right now the phm-worker crate has a hard dependency on defmt, which will likely cause problems. We should maybe introduce a shim that switches between log and defmt, sort of like embassy and smoltcp do currently.