Hello
I want to write some unit tests for my project. I do no want to test on hardware (embedded) as this overhead is to much hazzle for now.
I only need to test some functions, and class methods so i think there is no need to run on the target hardware (I also don’t have every possible ESP board )
So i made a new env with platform = native
.
But when running the tests, it tries to build the code and complains about a missing Arduino.h. Building the platform = arduino
envs works fine.
Do i miss something there?
1 Like
That’s the point of native tests – to use the native host compiler (for Windows/Linux/Mac) to test that code which is hardware independent (or mockable), so no Arduino.h
is available by default. What do you want your computer to do when when you call digitalWrite(LED_BUILTIN, HIGH);
?
See e.g. Redirecting... and the native and embedded tests for the calculator example.
Of course, you can still use techniques like mocking functions and objects, this thread gives some ideas.
Oh I think I misunderstood you. It accidently builds your project code which has a Arduino.h
dependency when it should not build that code at all? Then check the test options (docs), make sure all your to-be-tested code is in test/
or adapt test_build_project_src
accordingly and double check the above listed examples, especially the tutorial.
1 Like