PlatformIO Community

Unit test recommended structure multi-test



I am trying to implement unit testing, I have in the past used cpputest.

I am currently testing on native only, and using only a single test file I have successfully got tests working.

Now I want to start testing multiple modules. I am getting ‘multiple definition’ errors for setUp, main etc. if I try to add individual test files under separate folders

I run tests with CLI command
platformio test -e native

My test structure looks like
└── native
├── pulse_protocol
│ └── test_pulse_protocol.cpp
└── util
└── test_util_functions.cpp

Is there a specific way to implement multiple tests like this?



After posting, I tried removing the top level ‘native’ directory, and both tests were run under the native environment without issue.

However, I still can not add multiple test files under a single directory/module - I get the same errors as previous. Is there any way to do this?

├── pulse_protocol
│ ├── test_pulse_protocol_inputs.cpp
│ └── test_pulse_protocol_outputs.cpp
└── util
└── test_util_functions.cpp


See example with multi-tests structure