Native platform, arduino framework, wants board defn but native has no boards

I am trying to write a unit test that can be run on both the board and the native platform.

My platformio.ini for the native is:

[env]
framework = arduino

lib_deps =
    envirodiy/SDI-12@2.1.4
    https://github.com/DPIclimate/dpiclimate-12

monitor_speed = 115200
test_framework = googletest

[env:native]
platform = native
lib_compat_mode = off
lib_deps = googletest

When I try to run the tests I get:

$ pio test -e native
Verbosity level can be increased via `-v, -vv, or -vvv` option
Collected 1 tests

Processing test_utils in native environment
-----------------------------------------------------------------------------------------------
Building...
Please specify `board` in `platformio.ini` to use with 'arduino' framework
Building stage has failed, see errors above. Use `pio test -vvv` option to enable verbose output.
------------------------ native:test_utils [ERRORED] Took 0.22 seconds ------------------------

=========================================== SUMMARY ===========================================
Environment    Test        Status    Duration
-------------  ----------  --------  ------------
native         test_utils  ERRORED   00:00:00.223
========================== 1 test cases: 0 succeeded in 00:00:00.223 ==========================

The native platform has no boards, and doesn’t seem like it should need one.

I have been able to run the test by undefining ARDUINO and having a main() function rather than setup/loop, if I set ‘framework =’ (ie nothing).

What should my platformio.ini look like for the test to run on native under ArduinoFake?

Regards, David.

env gets inherited by all other environments. That means [env:native] will be expanded to include framework = arduino as well. You need to restructure your platformio.ini so that framework = arduino only appears in the embedded env’s, not the native env. See e.g. platformio-examples/unit-testing/arduino-mock at develop · platformio/platformio-examples · GitHub and platformio-examples/unit-testing/googletest/platformio.ini at develop · platformio/platformio-examples · GitHub.

Note: By using the extends = .. directory, you can create a new base environment from which all embedded environments can inherit (docs).