PlatformIO Community

Mocking with FakeIt

Hello, I would use FakeIt library, but I don’t know how. FakeIt documentation tell, that I should include fakeit.hpp file, but when I’m trying to do it, platform.io doesn’t see it. Unfortunately fakeIt library has more than one fakeit.hpp file. How to correctly include fakeIt library to platformio projects?

Sounds like Is it possible to search for headers recursively in a specific directory? - #7 by mnoureldin?

@maxgerhardt That’s my PlatformIO.ini file. What should I type there?

    ;settings:
[enviroment]
version = '"alpha"'
lib_deps =
        bblanchon/ArduinoJson @ ^6.18.5
build_flags =
        -DVERSION=${enviroment.version}



[test_enviroment]
test_lib_deps =
        https://github.com/eranpeer/FakeIt.git
lib_deps =
        ${enviroment.lib_deps}
        ${test_enviroment.test_lib_deps}
native_build_flags =
        -DTEST
        ${enviroment.build_flags}
common_build_flags =
        -DARDUINO
        ${test_enviroment.native_build_flags}



[platformio]
default_envs =
        nanoNew
        unoR3



;Arduino nano V3.0
[env:nanoNew]
platform = atmelavr
board = nanoatmega328new
framework = arduino
lib_deps = ${enviroment.lib_deps}
build_flags = ${enviroment.build_flags}



[env:test_nanoNew]
platform = atmelavr
board = nanoatmega328new
framework = arduino
lib_deps = ${test_enviroment.lib_deps}
build_flags = ${test_enviroment.common_build_flags}



;Arduino uno R3
[env:unoR3]
platform = atmelavr
board = uno
framework = arduino
lib_deps = ${enviroment.lib_deps}
build_flags = ${enviroment.build_flags}



[env:test_unoR3]
platform = atmelavr
board = uno
framework = arduino
lib_deps = ${test_enviroment.lib_deps}
build_flags = ${test_enviroment.common_build_flags}



;native
[env:native]
platform = native
lib_deps = ${test_enviroment.lib_deps}
build_flags = ${test_enviroment.native_build_flags}

Sorry I’m very busy in the moment to do in-depth analysis, but have you tried the ArduinoFake example which is intended for Mocking Arduino on embedded platforms? There is an official example at https://github.com/platformio/platformio-examples/tree/develop/unit-testing/arduino-mock.

No, I haven’t. Is ArduinoFake in early access? I’m scared to use early access software.

https://github.com/FabioBatSilva/ArduinoFake has had 3 releases and is well-used.

Ok, I think that’s solve my problem. Thank’s for help.