ArduinoFake icon indicating copy to clipboard operation
ArduinoFake copied to clipboard

how to handle arduino core libraries from other platforms?

Open peterus opened this issue 2 years ago • 1 comments

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?

peterus avatar Feb 01 '23 16:02 peterus

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.

hansmbakker avatar Jul 24 '23 21:07 hansmbakker