Failed to include one project library header file of many for Unity test

In my Arduino project the lib folder includes 23 sub-folders. Everything builds fine to create the binary for Arduino. When I try to compile for the Unity test environment the folder MqttMessageHandler is not included (#include “MqttMessageHandler.h” no such file or directory). I can force the header file to be included by giving a full relative path. The dependency graph does not include MqttMessageHandler so it isn’t compiled and I get a bunch of linker errors.

The folder structure under lib for each of the classes is:

Class
  +-src
     +-Class.cpp
  +-include
     +-Class.h

This applies to all the classes that work properly and the one that doesn’t. I’ve even checked the linux file system for trailing spaces in folder names.

I’ve tried moving the .h and .cpp files into the root class folder with no change.

I’ve moved them to the root of a working class which only served to break that class - perhaps won’t scan into sub-folders if there are files in the root - and didn’t make MqttMessageHandler work anyway.

Here’s the platformio.ini:

[platformio]
default_envs = megaatmega2560

[env]
build_flags =
  !echo '-D VERSION=\"'$(date +"%%Y%%m%%d_%%H%%M%%S")'\"'

[env:megaatmega2560]
board = megaatmega2560
framework = arduino
lib_deps = 
	DallasTemperature
	PubSubClient
  arduino-libraries/Ethernet@2.0.2
platform = atmelavr
monitor_speed = 38400
build_flags = 
  ${env.build_flags}

[env:test]
platform = native
build_type = test
test_framework = unity
test_ignore = 
  ignore/*
build_flags =
  ${env.build_flags}
  -D TEST_ENV

The source file that won’t include the header is the test file for MqttMessageHandler. It is in test/test_MqttMessageHandler. The source file includes 9 of the other classes without any problem.

The MqttMessageHandler class is one of the last ones created if that could have any bearing on the problem.

Thanks for the suggestions.

  • MqttMessageHandler is in the same file structure as all the includes that do work
  • I don’t understand what you mean by using an extra script
  • the include statement was copied and pasted from the non-test environment where it does work
  • I’ve added a Clean test target to eclipse that does “run --target clean -e test”. It runs without error, but there’s no change to the compile error.

Unfortunately, the answer came from an A.I. chatbot whose only intention was to place advertising links. For this reason the post was deleted.