arduino-libraries / ArduinoIoTCloud

Home Page:https://app.arduino.cc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use Catch2 with Arduino.h

Nathan-ma opened this issue · comments

Hello, Please could someone explain to be how to use Catch2 with Arduino.h? I'm really interested in starting to use it. And as it appears in your project, you guys are successfully using it!

Could you gentleman please share a bit of this knowledge?

Obviously I know how to use Catch2, What I don't know is how to enable Arduino framework into GNU so the compiler could interpret things such as : Serial or String.. etc!

Or maybe I'm thinking about this the wrong way, and I should be using avr-g++ to compile catch2? idk.

Thank you for your time!

Hi @Nathan-ma 👋

There will be a official Arduino Library Template repository (it has not yet been officially released but you can take a preview here) which highlights how to integrate unit tests with Catch2 and Arduino libraries. For a real-world example this library (ArduinoIoTCloud) is an excellent reference.

For now we use it mostly for verifying business-logic and algorithms (code that is mostly hardware-agnostic) by cross-compiling the code for the host-pc (x86, not ARM, not AVR). Hardware-Stubbing/Mocking like providing virtual Serial objects may be an option in the future (but will require serious development effort).

Cheers, Alxe

Thank you Alex! I end up using platformio for my unit test now! But for sure I will dig into these informations you mentioned !