FabioBatSilva / ArduinoFake

Arduino mocking made easy
https://platformio.org/lib/show/1689/ArduinoFake
MIT License
102 stars 47 forks source link

how to handle arduino core libraries from other platforms? #38

Open peterus opened 1 year ago

peterus commented 1 year ago

I am working a lot on ESP32 mcu's. This arduino core's have some libraries which are used a lot (WiFi, UDP, Ethernet, etc.).

  1. Do somebody know of a ESP32 Arduino Fake core/library?
  2. Is it possible to integrate this kind of libraries here? but I think this will make this project not really better for other core's (like AVR etc.)

how do you handle situations like this?

hansmbakker commented 1 year ago

I tried copying the public part of the relevant header files to a separate folder, including their dependencies.

I gave them a different name, like HTTPCLient_Mock.h, WiFiClient.h. I removed the #include for the Client class in WiFiClient.h and replaced it by class Client;

In my code I conditionally include the real or mocking headers:

#ifdef UNIT_TEST
#include "HTTPClient_Mock.h"
#else
#include <HTTPClient.h>
#endif

It feels like a lot of tinkering to get it right though. More guidance from the maintainer would be great here.